<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[J tricks - Little JIRA Tricks - Tutorials]]></title><link><![CDATA[https://www.j-tricks.com/tutorials]]></link><description><![CDATA[Tutorials]]></description><pubDate>Wed, 15 Apr 2026 14:30:06 -0400</pubDate><generator>Weebly</generator><item><title><![CDATA[JIRA Development Cookbook - Third Edition is officially published]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbook-third-edition-is-officially-published]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbook-third-edition-is-officially-published#comments]]></comments><pubDate>Tue, 11 Oct 2016 16:10:01 GMT</pubDate><category><![CDATA[book]]></category><category><![CDATA[summit]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/jira-development-cookbook-third-edition-is-officially-published</guid><description><![CDATA[Today is the first day of Atlassian Summit 2016. Excited about the upcoming announcements of awesome features and unexpected goodies? I am!To add to the excitement, here is a humble gift. JIRA Development Cookbook - Third Edition is now officially published.             The book is available for purchase at Packt website and Amazon.Packt: https://www.packtpub.com/application-development/jira-development-cookbook-third-editionAmazon: https://www.amazon.com/Jira-7-Development-Cookbook-Third/dp/178 [...] ]]></description><content:encoded><![CDATA[<div class="paragraph"><font size="3">Today is the first day of <a target="_blank" href="https://www.atlassian.com/summit">Atlassian Summit 2016</a>. Excited about the upcoming announcements of awesome features and unexpected goodies? I am!<br /><br />To add to the excitement, here is a humble gift. <strong>JIRA Development Cookbook - Third Edition</strong> is now officially published.</font><br /><br /></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/jira-development-cookbook-cover_2_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><br /><font size="3">The book is available for purchase at <strong>Packt</strong> website and <strong>Amazon</strong>.<br /><br /><strong>Packt</strong>: <a target="_blank" href="https://www.packtpub.com/application-development/jira-development-cookbook-third-edition">https://www.packtpub.com/application-development/jira-development-cookbook-third-edition</a><br /><strong>Amazon</strong>: <a target="_blank" href="https://www.amazon.com/Jira-7-Development-Cookbook-Third/dp/1785885618">https://www.amazon.com/Jira-7-Development-Cookbook-Third/dp/1785885618</a><br /><br />If you are interested in customizing your best project management software, JIRA, to unleash its full potential, grab your copy now!<br /><br />Hope you like it and I am excited to hear from you.<br /><br />PS: If you are at Summit, I invite you to meet me at the <strong>Go2Group</strong> booth. Talk to you soon!<br /><br /><em>Jobin Kuruvilla,<br />Author - JIRA Development Cookbook series</em></font><br /></div>]]></content:encoded></item><item><title><![CDATA[JIRA Development Cookbook - Third Edition. Coming soon..]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbook-third-edition-coming-soon]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbook-third-edition-coming-soon#comments]]></comments><pubDate>Fri, 26 Aug 2016 02:16:34 GMT</pubDate><category><![CDATA[book]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/jira-development-cookbook-third-edition-coming-soon</guid><description><![CDATA[The wait is almost over!         Watch this space.. [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:center;"><font size="4">The wait is almost over!</font><br /></div>  <div><div class="wsite-image wsite-image-border-hairline " style="padding-top:10px;padding-bottom:10px;margin-left:0px;margin-right:0px;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/jira-development-cookbook-cover_1_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:center;"><font size="4">Watch this space..</font><br /></div>]]></content:encoded></item><item><title><![CDATA[JIRA Development Cookbook(s) on sale!]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbooks-on-sale]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbooks-on-sale#comments]]></comments><pubDate>Sat, 12 Mar 2016 15:44:37 GMT</pubDate><category><![CDATA[book]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/jira-development-cookbooks-on-sale</guid><description><![CDATA[While we wait for the impending release of the next version of JIRA Development Cookbook, here is something to cheer you up.   JIRA Development Cookbook eBook(s) are on &#65279;SALE&#65279;!         Use the code JIRA500DEV while you order the the JIRA Development Cookbook eBook or the JIRA Development 5.x Development Cookbook eBook in the Packt website.Stay tuned for more news on the release of the next version of the JIRA Development Cookbook. Happy coding! [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font size="3">While we wait for the impending release of the <a target="_blank" href="http://www.j-tricks.com/tutorials/jira-development-cookbook-whats-next">next version</a> of JIRA Development Cookbook, here is something to cheer you up. </font><br /><br /></div>  <div class="paragraph" style="text-align:center;"><font size="3"><strong>JIRA Development Cookbook eBook(s) are on <span>&#65279;</span>SALE<span>&#65279;</span>!</strong></font><br /><br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/6720309_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><br /><font size="3">Use the code <strong>JIRA500DEV</strong> while you order the the <a target="_blank" href="http://bit.ly/1QqO9Td">JIRA Development Cookbook</a> <strong>eBook</strong> or the <a target="_blank" href="http://bit.ly/1OOM0Pc">JIRA Development 5.x Development Cookbook</a> <strong>eBook</strong> in the Packt website.<br /><br />Stay tuned for more news on the release of the next version of the <strong>JIRA Development Cookbook</strong>. Happy coding!</font><br /></div>]]></content:encoded></item><item><title><![CDATA[Atlassian Spring Scanner and NoSuchBeanDefinitionException]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/atlassian-spring-scanner-and-nosuchbeandefinitionexception]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/atlassian-spring-scanner-and-nosuchbeandefinitionexception#comments]]></comments><pubDate>Wed, 27 Jan 2016 01:52:13 GMT</pubDate><category><![CDATA[components]]></category><category><![CDATA[plugin framework]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/atlassian-spring-scanner-and-nosuchbeandefinitionexception</guid><description><![CDATA[NoSuchBeanDefinitionException is a notorious exception in the JIRA Development world. Some even have had nightmares about it I hear!But then, this is a well documented error and even we have attempted documenting it &#65279;here&#65279; - to save hours of debugging and, of course, to provide a good night's sleep!!With the latest Atlassian Plugin SDK though, it seems the nightmares are back. And I have seen a rising number of questions about this error in Atlassian Answers and other forums. Are y [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font size="3"><strong>NoSuchBeanDefinitionException</strong> is a notorious exception in the JIRA Development world. Some even have had nightmares about it I hear!<br /><br />But then, this is a well documented error and even we have attempted documenting it <span>&#65279;</span><a target="_blank" href="http://www.j-tricks.com/tutorials/component-import-gotchas-nosuchbeandefinitionexception">here</a><span>&#65279;</span> - to save hours of debugging and, of course, to provide a good night's sleep!!<br /><br />With the latest <strong>Atlassian Plugin SDK</strong> though, it seems the nightmares are back. And I have seen a rising number of questions about this error in Atlassian Answers and other forums. Are you one of those who ran into the same? If so, don't blame it on Atlassian or the plugin SDK. You are just ignorant, as I was for a good few hours, about the <a target="_blank" href="https://bitbucket.org/atlassian/atlassian-spring-scanner">Atlassian Spring Scanner</a> libraries.</font><br /><br /></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><font size="3">"Atlassian Spring Scanner is a set of libraries that make plugins faster to load and easier to develop.". It scans the source code to find special annotations and creates special index files in the JAR's META-INF directory. These index files are read at runtime to create the necessary Spring components and OSGI services.<br /><br />What does it mean though?<br /><br />Once you have the spring scanner plugin, and related dependencies, added in the <font color="#a82e2e">pom.xml</font>, it will not look for component definitions in the <font color="#a82e2e">atlassian-plugin.xml</font> and will, instead, look for scanner annotations. Even the dependency injection requires the special annotations in the code.<br /><br />And yes, spring scanner plugin is enabled by default in the <font color="#a82e2e">pom.xml</font> when you create the plugin skeleton, by running <font color="#a82e2e">atlas-create-jira-plugin</font>, using the latest plugin SDK. That means you will run into <strong>NoSuchBeanDefinitionException</strong> when you inject components in the constructor without using the required annotations. Or when you use <font color="#a82e2e">component-import</font> definitions inside the <font color="#a82e2e">atlassian-plugin.xml</font>. Or when you use <font color="#a82e2e">public="true"</font> to export one of your components. And so on..<br /><br />For example, let is create a simple skeleton plugin using the new Plugin SDK (6.1.2 as of now) and add a <strong>webwork</strong> module definition.<br /><br /><font color="#a82e2e">&lt;webwork1 key="plugin-scanner-action" name="Plugin Scanner Action" i18n-name-key="plugin-scanner-action.name"&gt;<br />&nbsp;&nbsp;&nbsp; &lt;description key="plugin-scanner-action.description"&gt;Demos how the scanner annotations work&lt;/description&gt;<br />&nbsp;&nbsp;&nbsp; &lt;actions&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action name="com.jtricks.jira.webwork.PluginScannerDemo" alias="PluginScannerDemo"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;view name="success"&gt;/templates/plugin-scanner-action/pluginscannerdemo/success.vm&lt;/view&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/action&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/actions&gt;<br />&lt;/webwork1&gt;</font><br /><br />In the action class, we can keep it simple by injecting the ever popular <strong>JiraAuthenticationContext</strong> interface, as shown below:<br /><br /><font color="#a82e2e">public class PluginScannerDemo extends JiraWebActionSupport {<br />&nbsp;&nbsp; &nbsp;private static final Logger log = LoggerFactory.getLogger(PluginScannerDemo.class);<br /><br />&nbsp;&nbsp; &nbsp;private final JiraAuthenticationContext authContext;<br /><br />&nbsp;&nbsp; &nbsp;private String currentUser;<br /><br />&nbsp;&nbsp; &nbsp;public PluginScannerDemo(JiraAuthenticationContext authContext) {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;super();<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.authContext = authContext;<br />&nbsp;&nbsp; &nbsp;}<br /><br />&nbsp;&nbsp; &nbsp;@Override<br />&nbsp;&nbsp; &nbsp;protected String doExecute() throws Exception {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (this.authContext.getLoggedInUser() != null) {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.currentUser = this.authContext.getLoggedInUser().getDisplayName();<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} else {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.currentUser = "Anonymous";<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return super.doExecute();<br />&nbsp;&nbsp; &nbsp;}<br /><br />&nbsp;&nbsp; &nbsp;public String getCurrentUser() {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return currentUser;<br />&nbsp;&nbsp; &nbsp;}<br />}</font><br /><br />And we can create a success view that prints the <strong>currentUser</strong>.<br /><br /><font color="#a82e2e">&lt;h1&gt;Welcome $!currentUser!&lt;/h1&gt;</font><br /><br />It looks very simple but you will run into the, you guessed it right, <strong>NoSuchBeanDefinitionException</strong> when this code is executed.<br /><br /><font color="#a82e2e">[INFO] [talledLocalContainer] 2016-01-26 10:52:19,659 http-nio-2990-exec-7 ERROR admin 652x237x3 zb3hwx 0:0:0:0:0:0:0:1 /secure/PluginScannerDemo.jspa [c.a.j.web.dispatcher.JiraWebworkActionDispatcher] Exception thrown from action 'PluginScannerDemo', returning 404<br />[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.jtricks.jira.webwork.PluginScannerDemo': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.jira.security.JiraAuthenticationContext]: : No qualifying bean of type [com.atlassian.jira.security.JiraAuthenticationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.jira.security.JiraAuthenticationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}</font><br /><br />We know that <strong>JiraAuthenticationContext</strong> is a public component and doesn't need a <font color="#a82e2e">component-import</font> definition. Even if we add it in the <font color="#a82e2e">atlassian-plugin.xml</font>, as described in one of our earlier <a target="_blank" href="http://www.j-tricks.com/tutorials/component-import-gotchas-nosuchbeandefinitionexception">tips</a>, that is not going to help with this error.<br /><br />This is where we need to start adding the new scanner annotations. Following are the important ones.<br /></font></div>  <div class="paragraph" style="text-align:left;"><ul><li><font size="2"><font color="#a82e2e">@ExportAsService</font>: Replaces <font color="#a82e2e">&lt;component ... public="true"&gt;</font> and exposes the class as a OSGi service.</font><br /></li><li><font size="2"><font color="#a82e2e">@Named</font> (JSR) or <font color="#a82e2e">@Component</font> (Spring): Replaces <font color="#a82e2e">&lt;component ...&gt;</font> definition.</font></li><li><font size="2"><font color="#a82e2e">@Autowired</font> or <font color="#a82e2e">@Inject</font>: Used for dependency injection</font></li><li><font size="2"><font color="#a82e2e">@ComponentImport</font>: Replaces <font color="#a82e2e">&lt;component-import ...&gt;</font> definition.</font></li><li><font size="2"><font color="#a82e2e">@ClasspathComponent</font>: Defined a component whose class is contained in some other library.</font></li><li><font size="2"><font color="#a82e2e">@ModuleType</font>: Replaces <font color="#a82e2e">&lt;module-type.. &gt;</font> definition.</font></li></ul><br /><font size="2">And you will find more annotations and finer details at <a target="_blank" href="https://bitbucket.org/atlassian/atlassian-spring-scanner">https://bitbucket.org/atlassian/atlassian-spring-scanner</a>.<br /><br />Our modified code, with all these annotations, will look like this:<br /><br /><font color="#a82e2e">@Named ("PluginScannerDemo")<br />public class PluginScannerDemo extends JiraWebActionSupport {<br />&nbsp;&nbsp; &nbsp;private static final Logger log = LoggerFactory.getLogger(PluginScannerDemo.class);<br /><br />&nbsp;&nbsp; &nbsp;@ComponentImport<br />&nbsp;&nbsp; &nbsp;private final JiraAuthenticationContext authContext;<br /><br />&nbsp;&nbsp; &nbsp;private String currentUser;<br /><br />&nbsp;&nbsp; &nbsp;@Inject<br />&nbsp;&nbsp; &nbsp;public PluginScannerDemo(JiraAuthenticationContext authContext) {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;super();<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.authContext = authContext;<br />&nbsp;&nbsp; &nbsp;}<br /><br />&nbsp;&nbsp; &nbsp;@Override<br />&nbsp;&nbsp; &nbsp;protected String doExecute() throws Exception {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (this.authContext.getLoggedInUser() != null) {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.currentUser = this.authContext.getLoggedInUser().getDisplayName();<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} else {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.currentUser = "Anonymous";<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return super.doExecute();<br />&nbsp;&nbsp; &nbsp;}<br /><br />&nbsp;&nbsp; &nbsp;public String getCurrentUser() {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return currentUser;<br />&nbsp;&nbsp; &nbsp;}<br />}</font><br /><br />And, voil&agrave;, Everything works as expected!<br /><br />You can find the full code attached at the end of this blog.<br /><br />But, if you want to stick with old style, maybe because you are upgrading a huge plugin, you can do that by removing the Spring Scanner plugin and its dependencies from the <font color="#a82e2e">pom.xml</font>. As simple as that! You can find the source code, for the above example, without the spring scanner attached as <strong>plugin-scanner-demo-old-style.zip</strong>.<br /><br /><em>Note that Spring Scanner is recommended because the code with annotations load significantly faster than traditional P2 plugins that require runtime transformation. As per Atlassian, local tests show plugins that took 5 seconds to load now load in under 2 seconds. Being more explicit about the code, using annotations, is indeed a fair trade-off, if that is the case.</em><br /><br />Hope you enjoyed this tip. You can read more such tips in the new version of <a target="_blank" href="http://www.j-tricks.com/tutorials/jira-development-cookbook-whats-next">JIRA Development Cookbook</a>, that is coming out soon. Stay tuned!</font></div>  <div><div style="margin: 10px 0 0 -10px"> <a title="Download file: plugin-scanner-demo.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/plugin-scanner-demo.zip"><img src="//www.weebly.com/weebly/images/file_icons/gz.png" width="36" height="36" style="float: left; position: relative; left: 0px; top: 0px; margin: 0 15px 15px 0; border: 0;" /></a><div style="float: left; text-align: left; position: relative;"><table style="font-size: 12px; font-family: tahoma; line-height: .9;"><tr><td colspan="2"><b> plugin-scanner-demo.zip</b></td></tr><tr style="display: none;"><td>File Size:  </td><td>21 kb</td></tr><tr style="display: none;"><td>File Type:  </td><td> zip</td></tr></table><a title="Download file: plugin-scanner-demo.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/plugin-scanner-demo.zip" style="font-weight: bold;">Download File</a></div> </div>  <hr style="clear: both; width: 100%; visibility: hidden"></hr></div>  <div><div style="margin: 10px 0 0 -10px"> <a title="Download file: plugin-scanner-demo-old-style.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/plugin-scanner-demo-old-style.zip"><img src="//www.weebly.com/weebly/images/file_icons/gz.png" width="36" height="36" style="float: left; position: relative; left: 0px; top: 0px; margin: 0 15px 15px 0; border: 0;" /></a><div style="float: left; text-align: left; position: relative;"><table style="font-size: 12px; font-family: tahoma; line-height: .9;"><tr><td colspan="2"><b> plugin-scanner-demo-old-style.zip</b></td></tr><tr style="display: none;"><td>File Size:  </td><td>21 kb</td></tr><tr style="display: none;"><td>File Type:  </td><td> zip</td></tr></table><a title="Download file: plugin-scanner-demo-old-style.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/plugin-scanner-demo-old-style.zip" style="font-weight: bold;">Download File</a></div> </div>  <hr style="clear: both; width: 100%; visibility: hidden"></hr></div>]]></content:encoded></item><item><title><![CDATA[JIRA Development Cookbook - What's next?]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbook-whats-next]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/jira-development-cookbook-whats-next#comments]]></comments><pubDate>Sat, 12 Dec 2015 17:47:59 GMT</pubDate><category><![CDATA[book]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/jira-development-cookbook-whats-next</guid><description><![CDATA[      [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/8273847_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>]]></content:encoded></item><item><title><![CDATA[Setting formatted dates using javascript in JIRA]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/setting-formatted-dates-using-javascript-in-jira]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/setting-formatted-dates-using-javascript-in-jira#comments]]></comments><pubDate>Sat, 10 May 2014 13:32:10 GMT</pubDate><category><![CDATA[ajs]]></category><category><![CDATA[javascript]]></category><category><![CDATA[user interface]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/setting-formatted-dates-using-javascript-in-jira</guid><description><![CDATA[Wow, it's been a while since the last post. Crazy schedule but this one is too cool to ignore!Did you ever want to populate a date field in JIRA but with all the formatting defined in JIRA itself? And maybe add, subtract days etc using javascript?      Well, it is easier than you think. And no need to write crazy javascript code to do all the calculations by yourself. Just offload the work to Moment.js! And that is exactly what JIRA does, thanks to Wojciech Urbanski from Atlassian for pointing t [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font size="3">Wow, it's been a while since the last post. Crazy schedule but this one is too cool to ignore!<br /><br />Did you ever want to populate a date field in JIRA but with all the formatting defined in JIRA itself? And maybe add, subtract days etc using javascript?<br /></font></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br />Well, it is easier than you think. And no need to write crazy javascript code to do all the calculations by yourself. Just offload the work to <a target="_blank" href="http://momentjs.com/">Moment.js</a>! And that is exactly what JIRA does, thanks to <u><em>Wojciech Urbanski</em></u> from Atlassian for pointing that out in this <a target="_blank" href="https://answers.atlassian.com/questions/209097/programmatically-assign-a-date-object-in-a-date-field">post</a>.<br /><br />For example, if you want to set the current date to "due date" in an issue, you can use this:<br /><br /><font color="#c23b3b">var due = moment(new Date());<br />var dateString = due.format(JIRA.translateSimpleDateFormat(AJS.Meta.get("date-dmy")));<br />AJS.$('#duedate').val(dateString); </font><br /><br />That's all!<br /><br />How about if you want to set the due date 5 days from now? It is again <u>Moment.js</u> that comes to the rescue.<br /><br /><font color="#c23b3b">var due = moment().add('days', 5);<br />var dateString = due.format(JIRA.translateSimpleDateFormat(AJS.Meta.get("date-dmy")));<br />AJS.$('#duedate').val(dateString); </font><br /><br />What about setting the date and time on a datetime custom field instead of just the date? Use <strong>date-complete</strong> instead of <strong>date-dmy</strong>.<br /><br /><font color="#c23b3b">var due = moment(new Date());<br />var dateString = due.format(JIRA.translateSimpleDateFormat(AJS.Meta.get("date-complete")));<br />AJS.$('#duedate').val(dateString); </font><br /><br />You can find the other available formats at <strong>atlassian-jira/includes/jquery/plugins/livestamp/moment.jira.i18n.js</strong>. Or checkout the page source for more such attributes that can be retrieved via <strong>AJS.Meta.get()</strong>.<br /><br />Yup, that is what I thought. Cool stuff!<br /></font></div>]]></content:encoded></item><item><title><![CDATA[JIRA notification messages]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/jira-notification-messages]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/jira-notification-messages#comments]]></comments><pubDate>Sun, 08 Dec 2013 16:49:54 GMT</pubDate><category><![CDATA[ajs]]></category><category><![CDATA[javascript]]></category><category><![CDATA[user interface]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/jira-notification-messages</guid><description><![CDATA[Ever wondered how the nice little JIRA notification messages are created? The ones you get when an issue is created in JIRA?         Doing this is so easy that you will want to try it out in every new plugin that you write!      All you need is to inject the following javascript snippet into the page:JIRA.Messages.showSuccessMsg('Your message goes here');Let me show you a simple demonstration of this. I am going to put this into the announcement banner so that I don't have to create a plugin to  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font size="3">Ever wondered how the nice little JIRA notification messages are created? The ones you get when an issue is created in JIRA?</font><br /></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/8760325_orig.png" alt="Picture" style="width:100%;max-width:685px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3">Doing this is so easy that you will want to try it out in every new plugin that you write!</font><br /></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br /><span>All you need is to inject the following javascript snippet into the page:<br /><br /><font color="#c00">JIRA.Messages.showSuccessMsg('Your message goes here');</font><br /><br />Let me show you a simple demonstration of this. I am going to put this into the announcement banner so that I don't have to create a plugin to inject this javascript ;)<br /><br />Let us say we need to show this message when a user visits the profile. All you need to do is to add this snippet in the Announcement banner.<br /><br /><font color="#c00">&lt;script &gt;<br />var pathname = window.location.pathname;<br />if (pathname.indexOf("ViewProfile.jspa") &gt;= 0)<br />{<br />&nbsp;&nbsp; JIRA.Messages.showSuccessMsg('You are viewing your profile, Success');<br />}<br />&lt;/script&gt;</font><br /><br />And the message will appear on the screen when you visit the profile.</span><br /></font></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/2773201_orig.png" alt="Picture" style="width:100%;max-width:851px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3">But, did you notice that the message didn't have a <strong>close</strong> button as you normally see in the <em>Create</em> notification? This is where you can pass properties to the function.<br /><br /><font color="#c00">&lt;script &gt;<br />var pathname = window.location.pathname;<br />if (pathname.indexOf("ViewProfile.jspa") &gt;= 0)<br />{<br />&nbsp;&nbsp; JIRA.Messages.showSuccessMsg('You are viewing your profile', {closeable: true});<br />}<br />&lt;/script&gt;</font><br /><br />Here we passed the <strong>closeable</strong> property to the same function and the message will now have a close option.<br /></font></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/3703401_orig.png" alt="Picture" style="width:100%;max-width:760px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3">Now, you can replace the <strong>showSuccessMsg</strong> function with <strong>showErrorMsg</strong> or <strong>showWarningMsg</strong> to get the appropriate message format.</font><br /></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/4253599_orig.png" alt="Picture" style="width:100%;max-width:738px" /> </a> <div style="display:block;font-size:90%">ERROR</div> </div></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/4490657_orig.png" alt="Picture" style="width:100%;max-width:743px" /> </a> <div style="display:block;font-size:90%">WARNING</div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3">In all the 3 cases, the message disappears itself after the default timeout of 10 seconds. If you need a bigger timeout, use the <strong>timeout</strong> property.<br /><br /><font color="#c00">&lt;script &gt;<br />var pathname = window.location.pathname;<br />if (pathname.indexOf("ViewProfile.jspa") &gt;= 0)<br />{<br />&nbsp;&nbsp; JIRA.Messages.showSuccessMsg('You are viewing your profile', {closeable: true, timeout: 60});<br />}<br />&lt;/script&gt;</font><br /><br />Are there any other properties? The only other property is <strong>type</strong> and you can use it when you use the generic function <strong>showMsg</strong> instead of <strong>showSuccessMsg</strong>, <strong>showErrorMsg</strong> or <strong>showWarningMsg</strong>. The possible type values are <strong>SUCCESS</strong>, <strong>ERROR</strong> or <strong>WARNING</strong>.<br /><br />For example:<br /><br /><font color="#c00">JIRA.Messages.showSuccessMsg('You are viewing your profile', {closeable: true, timeout: 60});</font><br /><br />is same as<br /><br /><font color="#c00">JIRA.Messages.showMsg('You are viewing your profile', {type: SUCCESS, closeable: true, timeout: 60});</font><br /><br />For more details on how these functions work and for more more useful functions like <strong>showReloadSuccessMsg</strong>, take a look at <strong>includes/jira/common/messages.js</strong> file. Hope you find it useful.<br /><br /><span><span><span>PS: If you find these little tutorials useful, you might also like the <a href="https://www.j-tricks.com/the-book.html">JIRA Development Cookbook</a>.</span></span></span><br /></font></div>]]></content:encoded></item><item><title><![CDATA[Date, DateTime and User picker fields]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/date-datetime-and-user-picker-fields]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/date-datetime-and-user-picker-fields#comments]]></comments><pubDate>Sun, 03 Nov 2013 01:31:08 GMT</pubDate><category><![CDATA[javascript]]></category><category><![CDATA[user interface]]></category><category><![CDATA[webwork actions]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/date-datetime-and-user-picker-fields</guid><description><![CDATA[With the evolution of JIRA over the years, it has a set of nice APIs or helper methods for doing pretty much everything. But one thing that I always have to look up while developing plugins is using date and user pickers in a velocity template.As usual, it is something that is really easy once you look it up. Here is a simplified version of what I have done in the last few versions of JIRA.      Let us create a sample plugin with a simple webwork action. How about an alias of Picker? Is there a  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font size="3">With the evolution of JIRA over the years, it has a set of nice APIs or helper methods for doing pretty much everything. But one thing that I always have to look up while developing plugins is using date and user pickers in a velocity template.<br /><br />As usual, it is something that is really easy once you look it up. Here is a simplified version of what I have done in the last few versions of JIRA.<br /></font></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br />Let us create a sample plugin with a simple webwork action. How about an alias of <strong>Picker</strong>? Is there a more obvious name to call this example? ;)<br /><br />&nbsp; <font color="#cc0000">&lt;webwork1 key="picker-module" name="PickerModule" i18n-name-key="picker-module.name"&gt;<br />&nbsp; &nbsp; &lt;description key="picker-module.description"&gt;Sample date and user picker in velocity templates&lt;/description&gt;<br />&nbsp; &nbsp; &lt;actions&gt;<br />&nbsp; &nbsp; &nbsp; &lt;action name="com.jtricks.jira.webwork.Picker" alias="Picker"&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;view name="success"&gt;/templates/picker-module/picker/success.vm&lt;/view&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/action&gt;<br />&nbsp; &nbsp; &lt;/actions&gt;<br />&nbsp; &lt;/webwork1&gt;</font><br /><br />As you can see, we just have a simple webwork actions and a velocity template associated with the <strong>success</strong> view. All we are going to do here is to create a form in the view with sample picker fields. I have generalized methods so that you can use it for as many picker fields as you want on the same page.<br /><br /><font size="4"><u>Date Picker field</u></font><br /><br />Really easy to do this! Couple of steps:<br /><br />1. Add this macro in the beginning of the template.<br /><br />&nbsp; <font color="#cc0000">#macro(datePopup $inputId $inputButton $dateFormat)</font><br /><font color="#cc0000">&nbsp; &lt;script language="javascript" &gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;Calendar.setup({<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; firstDay : 1,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputField : '$inputId',<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; button : '$inputButton',<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; align : 'Br',<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; singleClick : true,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showsTime : false,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; useISO8601WeekNumbers : false,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifFormat : '$dateFormat'<br />&nbsp; &nbsp; &nbsp; &nbsp;});<br />&nbsp; &nbsp;&lt;/script&gt;<br />&nbsp; &nbsp;#end</font><br /><br />2. Use the macro in the field group as shown below:<br /><br />&nbsp; &nbsp;<font color="#cc0000">&lt;div &gt;</font><br /><font color="#cc0000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;label for="uniqueDateId"&gt;Date Field Name&lt;/label&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input id="uniqueDateId" name="name" /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;a href="#" id="uniqueDateId_trigger" title="Enter your date field"&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;span &gt;&lt;/span&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/a&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#datePopup("uniqueDateId" "uniqueDateId_trigger" $dateFormat)<br />&nbsp; &nbsp; &lt;/div&gt;</font><br /><br />That's it!&nbsp;<br /><br />As you can see, the input field has a unique id (<strong>uniqueDateId</strong> in this example) and the anchor tag has a matching id which of the format <font color="#cc0000">${id_of_input_field}_trigger</font> (<strong>uniqueDateId_trigger</strong> in this example). Make sure pass this input field Id and anchor id to the datePopup macro we created in step 1.<br /><br />The result is what you can see here:<br /></font></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/5595858_orig.png" alt="Picture" style="width:100%;max-width:661px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br /><br /><font size="4"><u>DateTime Picker field</u></font><br /><br />This is much similar to Date field, except for the number of arguments passed to the macro. It takes a date time format and a time format as opposed to the date format. Following are the steps:<br /><br />1. Add a macro similar to what we did earlier.<br /><br />&nbsp; &nbsp;<font color="#cc0000">#macro(dateTimePopup $inputId $inputButton $dateTimeFormat $timeFormat)<br />&nbsp; &nbsp;&lt;script language="javascript" &gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Calendar.setup({<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;firstDay : 1,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inputField : '$inputId',<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;button : '$inputButton',<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;align : 'Br',<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;singleClick : true,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;showsTime : true,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;useISO8601WeekNumbers : false,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ifFormat : '$dateTimeFormat',<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;timeFormat : '$timeFormat'<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});<br />&nbsp; &nbsp; &nbsp;&lt;/script&gt;<br />&nbsp; &nbsp; &nbsp;#end</font><br /><br />The main difference is the formats. In the script, <strong>ifFormat</strong> uses a date time format instead of date format. There is also a <strong>timeFormat</strong> argument. Also&nbsp;<strong>showsTime</strong> argument is <strong>true</strong> instead of <strong>false</strong>.<br /><br />2. Use the macro similar to what we did for datePopup. The unique ids should be just like what we did there.<br /><br />&nbsp; &nbsp;<font color="#cc0000">&lt;div &gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;label for="uniqueDateTimeId"&gt;DateTime Field Name&lt;/label&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input id="uniqueDateTimeId" name="name" /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;a href="#" id="uniqueDateTimeId_trigger" title="Enter your date time field"&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;span &gt;&lt;/span&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/a&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#dateTimePopup("uniqueDateTimeId" "uniqueDateTimeId_trigger" $dateTimeFormat $timeFormat)<br />&nbsp; &nbsp; &lt;/div&gt;</font><br /><br />Unique input id is <strong>uniqueDateTimeId</strong> and anchor id is <strong>uniqueDateTimeId_trigger</strong>.&nbsp;Here is how the field will appear on screen:<br /></font></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/4839518_orig.png" alt="Picture" style="width:100%;max-width:716px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br /><font size="4"><u>User Picker field</u></font><br /><br />User picker is slightly different. Here we make use of JIRA's user picker browser where you can search for users based on name, email or group.&nbsp;<br /><br />In the page, we click on the user picker icon to open up the user picker browser as a popup window and when you click on the search result, it fills the form back with the result selected.<br /><br />Steps are as follows:<br /><br />1. Add a javascript function that opens up the user picker<br /><br />&nbsp; &nbsp;<font color="#cc0000">&lt;script language="javascript" &gt;</font><br /><font color="#cc0000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;function openUserPickerWindow(element){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var vWinUsers = window.open('$!requestContext.canonicalBaseUrl/secure/popups/UserPickerBrowser.jspa?formName=jiraform&amp;multiSelect=false&amp;element=' + element, 'UserPicker', 'status=yes,resizable=yes,top=100,left=200,width=580,height=750,scrollbars=yes');<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vWinUsers.opener = self;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vWinUsers.focus(); &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &lt;/script&gt;</font><br /><br />The <strong>openUserPickerWindow</strong> method just opens up a user picker browser popup with the element attribute as the source input id (<strong>element</strong> variable). Note that the <strong>formName</strong> in the example is <strong>jiraform</strong> and change it as appropriate.<br /><br />2. Invoke the function when you click on the user picker icon.<br /><br />&nbsp; &nbsp; <font color="#cc0000">&lt;div &gt;</font><br /><font color="#cc0000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for="uniqueUserId"&gt;User Field Name&lt;/label&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input id="uniqueUserId" name="lead"/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;a href="javascript:openUserPickerWindow('uniqueUserId');"&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;img title="Ente the user name" name="multiuserImage" src="$!requestContext.canonicalBaseUrl/images/icons/filter_public.gif" hspace="0" height="16" width="16" border="0" align="absmiddle" &gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/a&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/div&gt;</font><br /><br />Here also the input field has a unique id (<strong>uniqueUserId</strong> in the example) and that is passed in the anchor tag. You can change the icon as you want in the image tag.<br /><br />Once added, the field appears on the form like this:<br /></font></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/9402946_orig.png" alt="Picture" style="width:100%;max-width:436px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><br /><font size="3">When you click on the user browser icon, it opens up the popup as shown below:</font><br /></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/9641272_orig.png" alt="Picture" style="width:100%;max-width:884px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><br /><font size="3">When you click on the 'admin' row, uniqueUserId on the form is populated as shown.</font><br /></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/4200076_orig.png" alt="Picture" style="width:100%;max-width:509px" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br />Yeah right, you have seen it a lot in JIRA ;)<br /><br />The example code is uploaded at the end of the tutorial and you can run the webwork action using the URL&nbsp;<a href="http://localhost:2990/jira/secure/Picker.jspa" target="_blank">http://localhost:2990/jira/secure/Picker.jspa</a>.<br /><br />That's all. 3 simple pickers, easy steps. How about the Ajax user search? Well, some other day :P<br /><br /></font></div>  <div><div style="margin: 10px 0 0 -10px"> <a title="Download file: picker-plugin.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/picker-plugin.zip"><img src="http://beta2.weebly.com/weebly/images/file_icons/gz.png" width="36" height="36" style="float: left; position: relative; left: 0px; top: 0px; margin: 0 15px 15px 0; border: 0;" /></a><div style="float: left; text-align: left; position: relative;"><table style="font-size: 12px; font-family: tahoma; line-height: .9;"><tr><td colspan="2"><b> picker-plugin.zip</b></td></tr><tr style="display: none;"><td>File Size:  </td><td>30 kb</td></tr><tr style="display: none;"><td>File Type:  </td><td> zip</td></tr></table><a title="Download file: picker-plugin.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/picker-plugin.zip" style="font-weight: bold;">Download File</a></div> </div>  <hr style="clear: both; width: 100%; visibility: hidden"></hr></div>]]></content:encoded></item><item><title><![CDATA[Component [Import] Gotchas - NoSuchBeanDefinitionException]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/component-import-gotchas-nosuchbeandefinitionexception]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/component-import-gotchas-nosuchbeandefinitionexception#comments]]></comments><pubDate>Mon, 15 Jul 2013 03:37:21 GMT</pubDate><category><![CDATA[components]]></category><category><![CDATA[plugin framework]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/component-import-gotchas-nosuchbeandefinitionexception</guid><description><![CDATA[Ever since Plugins 2.0 was introduced, I have come across the NoSuchBeanDefinitionException more than anything else.And this happens when you try to inject a JIRA component in the constructor. Following is a typical example.      [INFO] [talledLocalContainer] Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.jtricks.component-tricks-tests [105]: Unable to resolve 105.0: missing requirement [105.0] package; (package=com.jtricks)[INFO] [talledLocalContainer] &nbsp; [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font size="3">Ever since Plugins 2.0 was introduced, I have come across the NoSuchBeanDefinitionException more than anything else.<br /><br />And this happens when you try to inject a JIRA component in the constructor. Following is a typical example.<br /></font></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br /><font color="#CC0000">[INFO] [talledLocalContainer] Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.jtricks.component-tricks-tests [105]: Unable to resolve 105.0: missing requirement [105.0] package; (package=com.jtricks)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3409)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.apache.felix.framework.Felix.startBundle(Felix.java:1709)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:417)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; ... 53 more<br />[INFO] [talledLocalContainer] <strong>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.sal.api.user.UserManager] is defined: Unsatisfied dependency of type [interface com.atlassian.sal.api.user.UserManager]: expected at least 1 matching bean</strong><br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:622)<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:584)</font><br /><br />Fortunately, the fix is a simple one. Atlassian gives the <a target="_blank" href="https://developer.atlassian.com/display/DOCS/Component+Import+Plugin+Module">component-import</a> plugin module. For the above error, all you need to do is to add the following in the atlassian-plugin.xml file.<br /><br /><font color="#CC0000">&lt;component-import key="userManager" interface="com.atlassian.sal.api.user.UserManager"/&gt;</font><br /><br />You would imagine the same will work for every component, Wouldn't you? Unfortunately, that is not the case!<br /><br />Here is an example: <strong>JiraDurationUtils</strong>.<br /><br /><font color="#CC0000">[INFO] [talledLocalContainer] Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.jira.util.JiraDurationUtils] is defined: Unsatisfied dependency of type [class com.atlassian.jira.util.JiraDurationUtils]: expected at least 1 matching bean<br />[INFO] [talledLocalContainer] &nbsp;&nbsp;&nbsp; at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)</font><br /><br />Naturally, one would add the <strong>component-import</strong> tag for the class. I added the following:<br /><br /><font color="#CC0000">&lt;component-import key="jiraDurationUtils" interface="com.atlassian.jira.util.JiraDurationUtils" /&gt;</font><br /><br />This fixed the above error but along came another!<br /><br /><font color="#CC0000">[INFO] [talledLocalContainer] 2013-07-12 00:11:44,650 pool-5-thread-3 ERROR admin 11x1420x1 xq2dkb 127.0.0.1 /rest/plugins/1.0/ [plugin.osgi.factory.OsgiPlugin] Never resolved service '&amp;jiraDurationUtils' for plugin 'com.jtricks.component-tricks' with filter (object.atlassian.jira.util.JiraDurationUtils)</font><br /><br />So, how is <strong>JiraDurationUtils</strong> different from other components? If you look at the JIRA source, <strong>ContainerRegistrar</strong> class to be exact, you will see that the JiraDurationUtils component is registered as an internal class.<br /><br /><font color="#CC0000">register.implementation(INTERNAL, JiraDurationUtils.class);</font><br /><br />And that is exactly what causes the new exception.<br /><br />Fortunately, the fix is again an easy one. Instead of using <strong>component-import</strong> in this case, assume <strong>JiraDurationUtils</strong> as a class in your plugin (which is of course imported via <strong>jira-api</strong> dependency). To make it available for constructor injection, define the class as a <strong>component</strong> in the <strong>atlassian-plugin.xml</strong>. Int this case, the definition will be as follows:<br /><br /><font color="#CC0000">&lt;component key="jiraDurationUtils" name="JIRA Duration Utils" class="com.atlassian.jira.util.JiraDurationUtils"&gt;<br />&lt;/component&gt;</font><br /><br />That's all. Everything will work fine and you don't need the <strong>component-import</strong> anymore.<br /><br />Want another example? Take <strong>ComponentLocator</strong> interface. Instead of<br /><br /><font color="#CC0000">&lt;component-import key="componentLocator" interface="com.atlassian.jira.util.ComponentLocator" /&gt;</font><br /><br />you will end up adding the following:<br /><br /><font color="#CC0000">&lt;component key="componentLocator" name="Component Locator" class="com.atlassian.jira.util.JiraComponentLocator"&gt;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;interface&gt;com.atlassian.jira.util.ComponentLocator&lt;/interface&gt;<br />&lt;/component&gt;</font><br /><br />Attached is a sample listener code for you to try it out. Till the next one, enjoy the recipes in <a target="_blank" href="http://www.j-tricks.com/1/post/2013/04/jira-5x-development-cookbook.html">JIRA 5.x Development cookbook</a> ;)<br /></font></div>  <div><div style="margin: 10px 0 0 -10px"> <a title="Download file: component-tricks.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/component-tricks.zip"><img src="http://www.weebly.com/weebly/images/file_icons/gz.png" width="36" height="36" style="float: left; position: relative; left: 0px; top: 0px; margin: 0 15px 15px 0; border: 0;" /></a><div style="float: left; text-align: left; position: relative;"><table style="font-size: 12px; font-family: tahoma; line-height: .9;"><tr><td colspan="2"><b> component-tricks.zip</b></td></tr><tr style="display: none;"><td>File Size:  </td><td>16 kb</td></tr><tr style="display: none;"><td>File Type:  </td><td> zip</td></tr></table><a title="Download file: component-tricks.zip" href="https://www.j-tricks.com/uploads/5/0/1/5/5015576/component-tricks.zip" style="font-weight: bold;">Download File</a></div> </div>  <hr style="clear: both; width: 100%; visibility: hidden"></hr></div>]]></content:encoded></item><item><title><![CDATA[Win A Free Copy of Packt's JIRA 5.x Development Cookbook!!]]></title><link><![CDATA[https://www.j-tricks.com/tutorials/win-a-free-copy-of-packts-jira-5x-development-cookbook]]></link><comments><![CDATA[https://www.j-tricks.com/tutorials/win-a-free-copy-of-packts-jira-5x-development-cookbook#comments]]></comments><pubDate>Tue, 11 Jun 2013 02:40:48 GMT</pubDate><category><![CDATA[book]]></category><guid isPermaLink="false">https://www.j-tricks.com/tutorials/win-a-free-copy-of-packts-jira-5x-development-cookbook</guid><description><![CDATA[We are pleased to announce that we are organizing a giveaway especially for you. All you need to do is just comment below the post and win a free copy of JIRA 5.x Development Cookbook. Two lucky winners stand a chance to win copy of the book. Keep reading to find out how you can be one of the Lucky One.             Overview of JIRA 5.x Development CookbookExtend and customize JIRA; work with custom fields, workflows, reports, gadgets, JQL functions, plugins, and moreCustomize the look and feel o [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font size="3">We are pleased to announce that we are organizing a giveaway especially for you. All you need to do is just comment below the post and win a free copy of JIRA 5.x Development Cookbook. <br /><br />Two lucky winners stand a chance to win copy of the book. Keep reading to find out how you can be one of the Lucky One.<br /><br /></font></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.j-tricks.com/uploads/5/0/1/5/5015576/458259047.png?625" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font size="3"><br /><strong>Overview of JIRA 5.x Development Cookbook<br /></strong></font><ul><li><font size="3">Extend and customize JIRA; work with custom fields, workflows, reports, gadgets, JQL functions, plugins, and more</font></li><li><font size="3">Customize the look and feel of your JIRA user interface by adding new tabs, web items and sections, drop down menus, and more<br /></font></li><li><font size="3">Master JQL (JIRA Query Language) that enables advanced searching capabilities through which users can search for issues in their JIRA instance and then exploit all the capabilities of the issue navigator</font><br /></li></ul><font size="3"><br /><strong>How to Enter?</strong><br /><br />Simply post your expectations from this book in comments section below. You could be one of the 2 lucky participants to win the copy.<br /><br /><strong>DeadLine</strong><br /><br />The contest will close on 10th July 2013, a month from today. Winners will be contacted by email, so be sure to use your real email address when you comment!<br /><br /><u>Note from Packt</u>:<br /><br /><font color="#FF0000">Winners residing only in the USA and Europe would get a chance to win print copies. Others would be provided with eBook copies.</font><br /><br /><strong><span>Is it worth it?</span></strong><br /><br /><span>Maybe ;) Listen to couple of reviews on JIRA Development Cookbook!</span></font><br /></div>  <blockquote style="text-align:left;"><font size="2">"Jobin Kuruvilla, an experienced JIRA consultant and plugin developer,  set out on the ambitious task to write a detailed and thorough book  about JIRA plugin development. The result? A well crafted 450+ page book  that starts by introducing the reader to Atlassian&rsquo;s plugin framework  and ends with useful recipes usually gained only by weathered  experience. It&rsquo;s a great read for Atlassian plugin developers at all  levels.</font>"<br /><br /><a target="_blank" href="http://blogs.atlassian.com/2012/02/jira-development-cookbook-a-book-by-jobin-kuruvilla/"><font size="2"><span>Read More...</span></font></a><br /></blockquote>  <blockquote style="text-align:left;"><font size="2">"I felt compelled to write a review of this book because I think it  deserves it, it's a must-have for a JIRA plugin programmer. Before  writing this, I thought I'd write a more in-depth review. Surprisingly, I  discovered that enumerating&nbsp;each and every subject this book covers&nbsp;was  <em style="">not</em> necessary: it's a homogeneous, extensive and well organized book.<br /></font> <font size="2"><br /> From a developer standpoint, it's an effective and efficient mean to  learn the subject and get the job done, much better than any tutorial  I've seen so far. Together with the official Atlassian JIRA  documentation, this book is pretty much <em style="">all you need</em>."<br /><br /><a title="" target="_blank" href="http://thegreyblog.blogspot.com/2012/02/book-review-jira-development-cookbook.html"><span>Read More...</span></a><br /></font></blockquote>  <div class="paragraph" style="text-align:left;"><font size="3">So, there it is! Grab this chance and become a proud owner of JIRA 5.x Development Cookbook. And don't forget to review the same so that we can make it even better in the next edition!<br /><br />And, if you can't wait a month, order your copy today at <a target="_blank" href="http://www.amazon.com/JIRA-Development-Cookbook-Jobin-Kuruvilla/dp/1782169083/">Amazon</a> or <a target="_blank" href="http://www.packtpub.com/jira-5-x-development-cookbook/book">Packt</a> website.<br /></font></div>]]></content:encoded></item></channel></rss>