Creating Mail handler plugin GUI

aas October 17, 2019

I try to create mail handler plugin folowwing "Creating a custom mail handler for Jira" tutorial.   I can't get parameters in class EditDemoHandlerDetailsWebAction.java, which I add in to the form, when I try to create new mail handler. But I can get parameters when I try to edit already existing incoming mail handler, in that time I see parameters in copyServiceSettings method. Do I need override some more methods of AbstractEditHandlerDetailsWebaction class or something else?   Unfortunately I can't add code of my  EditDemoHandlerDetailsWebAction class because message marked as spam( Any help will be very important, thanks.

1 answer

0 votes
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2019

Hello,

Have you tried to add vm resource file in <actions> tag as described in the tutorial?

You need to add getter and setter methods in EditDemoHandlerDetailsWebAction class (assuming it is your action class) per each inputs in your vm file.

aas October 18, 2019

Hello. Here is part of my atlassian-plugin. xml where I add EditDemoHandlerDetailsWebAction class and editDemoHandlerDetails.vm

<webwork1 key="actions" name="UI" class="java.lang.Object">
<actions>
<action name="com.example.plugins.tutorial.jira.mailhandlerdemo.EditDemoHandlerDetailsWebAction"
alias="EditDemoHandlerDetails"
roles-required="admin">
<view name="input">/view/editDemoHandlerDetails.vm</view>
<view name="securitybreach">/secure/views/securitybreach.jsp</view>
</action>
</actions>
</webwork1>

 is that OK? 

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2019

Do you have editDemoHandlerDetails.vm in the right folder? And does your EditDemoHandlerDetailsWebAction class contain those fields' (in vm file) getter/setter?

aas October 18, 2019

editDemoHandlerDetails.vm is in src\main\resources\view\

Here's my vm file

## couple of available navigation helpers
#set ($modifierKey = $action.browserUtils.getModifierKey())
#set ($submitAccessKey = $i18n.getText('AUI.form.submit.button.accesskey'))
#set ($submitTitle = $i18n.getText('AUI.form.submit.button.tooltip', [$submitAccessKey, $modifierKey]))
#set ($cancelAccessKey = $i18n.getText('AUI.form.cancel.link.accesskey'))
#set ($cancelTitle = $i18n.getText('AUI.form.cancel.link.tooltip', [$cancelAccessKey, $modifierKey]))
<html>
<head>
<title>$action.handlerName</title>
</head>
<body>

<form class="aui" action="EditDemoHandlerDetails.jspa" method="POST" name="mailHandlerForm" id="mailHandlerForm">
<div class="form-body">
<h2>$action.handlerName</h2>
<span class="global-errors-location">
#if ($action.getHasErrorMessages())
#foreach ($error in $action.getFlushedErrorMessages())
#AUImessage("error" "" $textutils.htmlEncode(${error}) "" "" "" "true")
#end
#end
</span>
<input type="hidden" name="atl_token" value="$atl_token">
<label>$i18n.getText('demohandler.project')<input type="text" class="text" id="issue-key" name="issueKey" value="$!textutils.htmlEncode($issueKey)"></label>
<label>$i18n.getText('demohandler.issueType')<input type="text" class="text" id="issueType" name="issueType" value="$!textutils.htmlEncode($issueType)"></label>
<label><input type="text" class="text" id="reporterusername" name="reporterusername" value="$!textutils.htmlEncode($reporterusername)">$i18n.getText('demohandler.reporterusername')</label>
<label>CheckBox1 <input type="checkbox" name="checkBox"/>CheckBox222</label>

<div class="buttons-container form-footer">
<div class="buttons">
#if ($action.editing)
#set ($addButtonLabel = $i18n.getText('common.words.save'))
#else
#set ($addButtonLabel = $i18n.getText('common.forms.add'))
#end
<input id="addButton" type="submit" class="button" value="$!addButtonLabel" accesskey="$submitAccessKey" title="$submitTitle">
<a href="IncomingMailServers.jspa" class="cancel" accesskey="$cancelAccessKey" title="$cancelTitle">$i18n.getText("AUI.form.cancel.link.text")</a>
</div>

</div>
</div>
</form>
</body>
</html>

You mean, that I need add getter/setter for all inputs in vm file?

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2019

You can add input fields (text, radio, check, select) to this vm file and access them in your java file.

Also you can get pre-defined values in your vm file by $action.field 

And yes, you have to add getter/setter

aas October 18, 2019

Thanks a lot! I'll inform when i try

Suggest an answer

Log in or Sign up to answer