Dynamically add menu item on section

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi all!

I have to implement a feature where I need a variable number (not known at compilation time) of menu items to display in a section (thus I need to generate them dynamically with java or js code).

Is it possible?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi,

You can do it with java.

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Great :) could you give more infos please?

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi,

You know how to add a new drop-down menu on the top
navigation bar? or add web-item

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Yep, from atlassian-plugin.xml... not with java code

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

To do it dynamicly you must code with java some trucs

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Ok, I get it... Now could you give an exemple about how to do this :) ?

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi,

Yes, but it may take some time.

The following is a step-by-step to do it:

1. Create a web section in the system top navigationbar in atlassian-plugin.xml and post me your code.


Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

so far it look like this:

<web-item key="printing_link" name="Printing Link" section="system.top.navigation.bar"
weight="47">
<label>Printing</label>
<link linkId="printing_link"></link>
<condition
class="com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition" />
</web-item>
<web-section key="printing_section" name="Printing Section"
location="printing_link" weight="10">
</web-section>
<web-item key="view_print_history_link" name="View Print History"
section="printing_link/printing_section" weight="10">
<label>View Print History</label>
<link linkId="view_print_history_link">/secure/FatcaPrintHistory.jspa</link>
</web-item>
<web-item key="view_failure_history_link" name="View Failures History"
section="printing_link/printing_section" weight="11">
<label>View Failures History</label>
<link linkId="view_failure_history_link">/secure/FatcaFailureHistory.jspa</link>
</web-item>

<webwork1 key="printing_action" name="Printing History Actions"
class="java.lang.Object">
<actions>
<action name="com.xxx.actions.PrintHistory"
alias="FatcaPrintHistory">
<view name="input">/templates/com/xxx/actions/printhistory.vm
</view>
</action>
<action
name="com.xxx.actions.FailureHistory"
alias="FatcaFailureHistory">
<view name="input">/templates/com/xxx/actions/printfailed.vm
</view>
</action>
</actions>
</webwork1>

I would like to generate a random number of web items under the "printing_link/printing_section"

Thanks in advance :)

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi,

Your jira version?

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013
This is the part that interests me

<web-item key="printing_link" name="Printing Link" section="system.top.navigation.bar"
weight="47">
<label>Printing</label>
<link linkId="printing_link"></link>
<condition
class="com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition" />
</web-item>
<web-section key="printing_section" name="Printing Section"
location="printing_link" weight="10">
</web-section>
<web-item key="view_print_history_link" name="View Print History"
section="printing_link/printing_section" weight="10">
<label>View Print History</label>
<link linkId="view_print_history_link">/secure/FatcaPrintHistory.jspa</link>
</web-item>
<web-item key="view_failure_history_link" name="View Failures History"
section="printing_link/printing_section" weight="11">
<label>View Failures History</label>
<link linkId="view_failure_history_link">/secure/FatcaFailureHistory.jspa</link>
</web-item>

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

I don't understant. You want me to post the code of my templates?

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi,

I devlop in jira 5.2.8

Second step:

Create a class that implement the SimpleLinkFactory interface.

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi,

No, i don't need your templates and actions.

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Third step:

add this to your atlassian-plugin.xml

&lt;!-- dynamic web item --&gt;
	&lt;simple-link-factory key="dynamic-factory" name="Dynamic Link Factory" section="printing_link/printing_section"  i18n-name-key="Dynamic menu" weight="30" lazy="true"  
	class="ridan.link.dynamic.DynamicLinkFactory"/&gt;

Rebuild and you have this:

Good luck

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi it works

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Hi, It work ?

I can't download print screen

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Perfect!! Thank you :)

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Please, accept this answer to help others

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Yeah, the print screen does not work but I don't need it :)

Thanks again for your snippets!

3 votes
Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2014

Hi All,

SimpleLinkFactory  is deprecated in JIRA 6.3 onwards, I went through API and studied to use WebItemProvider instead SimpleLinkFactory but when I run the plugin it threw cast exception.

, To resolve case exception I used 


<web-item-provider key="key" section="section"
name="Name"
i18n-name-key="i18nNmKey"
class="com.ora.ClassName"/>

and class implements WebItemProvider

for more info related to https://answers.atlassian.com/questions/11970940

 

Regards

Onkar Ahire
TAGS
AUG Leaders

Atlassian Community Events