Hello, I wrote template in Velocity
<header class="aui-page-header">
<div class="aui-page-header-inner">
<div class="aui-page-header-main">
<h2><em>DDL Configuration Page</em></h2>
</div>
<div class="aui-page-header-actions">
<div class="aui-buttons">
<a id="add-issue-type" class="aui-button">
Back
</a>
</div>
</div>
</div>
<form method="post" id="addGroup">
<div class="aui-group">
<div class="aui-item">
<div class="field-group">
<label for="text-input">Name<span class="aui-icon"></span></label>
<input class="text" type="text" id="d-fname" name="d-fname" title="first name">
</div>
</div>
<div class="aui-item">
<div class="field-group">
<label for="dBase">Type</label>
<select class="select" id="dBase" name="dBase" title="database select">
<option>Chose a type</option>
<option>JQL</option>
<option>Function</option>
<option>Rest</option>
</select>
</div>
</div>
<div class="aui-item">
<label>Date</label>
<input class="aui-date-picker" id="demo-range-always" type="date" max="2099-01-05" min="2011-12-25" />
</div>
<div class="aui-item">
<button class="aui-button">Select</button>
</div>
</div>
</form>
</header>
This looks pretty fine for me. The next step is, that I want to transfer this 3 variables to my method in Java class that accepts those parameters.
public String getTestMethodFromEntry(){
log.info("METHOD to ADD SERIVCE:");
ddlPanelEntrySerivce.addDDLEntry("test", "test", "test");
ddlPanelEntrySerivce.addDDLEntry("test", "test", "test");
ddlPanelEntrySerivce.addDDLEntry("test", "test", "test");
return String.valueOf(ddlPanelEntrySerivce.getEntriesByType("test"));
}
Hello Stephen,
Your question is not clear for me but I can say that you can pass parameters from Velocity to java object instance.
First you should inject your Java class instance to velocity,
map.put("ddlPanelEntryService", ddlPanelEntryService)
then you can use this variable in your velocity file using dollar sign
$ddlPanelEntryService.addDDLEntry("param1", "param2", "param3")
I hope I wasn't missing anything
I have another requirement, and would like to know how it can be archived.
In the below screen the ticket is now in the status "In-Progress", upon changing the status to DONE , is there any option to check if the user has entered all the Status, Remarks field for all checkpoints under the GLOBAL CONFIGURATION and to show a custom message if any row data is not filled in .
In the below screen for Checkpoint "Test in Progress" , STATUS and REMARKS are not filled, and if user does the transition of STATUS from In-progress to DONE, the user should be alerted to fill the data.
My VM file is as below,
<style type="text/css">
.init-template-div {
margin-left: 5px;
border: 1px dashed #ccc;
border-radius: 0;
padding: 7px;
transition: background-color 0.01s linear 0.01s;
position: relative;
text-align: center;
}
.init-template-div > div {
padding: 4px 0;
}
</style>
<script language="javascript" type="text/javascript">
function myFunction() {
//alert("aaa")
//var x = document.getElementById('checkPoint').value;
/*AJS.ajaxSetup({
baseUrl: "http://localhost:8090/jira" // The base url of your instance
});
AJS.ajax({
url : '/saveConfigDetails',
type: 'POST',
data : {remarks :x}, // form data
cache : false,
success: function(response){
alert('Success');
}
});*/
//alert(x);
}
</script>
<div id="issue-left" class="module toggle-wrap">
<form class="aui top-label" style="margin-top: 15px;" method="POST">
<table class="aui panelTableHeader">
<thead>
<tr>
<th class="element-medium-header">Checkpoints</th>
<th class="element-medium-header">Status</th>
<th class="element-xsmall-header">Remarks</th>
</tr>
</thead>
<tbody class="container">
<!--#if ($issueCheckPointConfiguration.isEmpty())
<tr class="elements-row grey-rows-on-edit ">
<td headers="coyxsnmhe" class=""><div>No Saved Records</div></td>
<td headers="bgd3200zb" class=""><div></div></td>
<td headers="47ujln567" class=""><div></div></td>
</tr>
#end-->
#set($i = 0)
#foreach( $issueCheckPointConfig in $issueCheckPointConfiguration )
#set($i = $i+1)
<tr class="elements-row grey-rows-on-edit " data-row_id="vfvfs5ks2" id="$i">
<td headers="coyxsnmhe" class="">
<input type="hidden" id="checkPoint" name="checkPoint" value="$issueCheckPointConfig.getCheckPoint()">
<div>$issueCheckPointConfig.getCheckPoint()</div></td>
<td headers="bgd3200zb" class="">
<div>
<select name="status" id="status" >
<option value="Select">Select</option>
<option selected>$issueCheckPointConfig.getStatus()</option>
<option value="YES" >YES</option>
<option value="NO" >NO</option>
<option value="NA" >NA</option>
</select>
</div></td>
<td headers="47ujln567" class="">
<div>
<input type="text" id="remarks" name="remarks" class="text auiTextInput long-field"
value="$issueCheckPointConfig.getRemarks()">
</div>
</td>
</tr>
#end
<td headers="47ujln567" class=""><div>
#if($globalConfigurationDetailsList.size() > 0 )
<button class="aui-button aui-button-compact marginRight" aria-disabled="false"
onclick="myFunction()">Save</button>
#end
</div>
</td>
</tbody>
</table>
</form>
</div>
Thanks in Advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to resolve the issue, by developing a plugin which can be configured as a validator in the WorkFlow.
Thanks ..
But i have another issue here.
If you look at the above screen shot in my previous comment, i am able to save the Global Configuration. ie, using the URL http://localhost:2990/jira/browse/TEST-2
There are other was by which we can view and update fields in the ticket like accessing the URL
http://localhost:2990/jira/projects/TEST/issues/TEST-2?filter=allopenissues
Like as below,
But from this screen my Java method is not being called.Can you please let me know what might be the issue.
The atlassian-plugin.xml is as below,
<web-panel name="IssueCheckPointsConfiguration" i18n-name-key="due-date-indicator.name" key="due-date-indicator" location="atl.jira.view.issue.left.context" weight="200">
<description key="due-date-indicator.description">Display Global Configuration</description>
<label key="global-configurations.label"></label>
<context-provider class="com.tel.plugins.tutorial.globalConfig.IssueCheckPointsConfiguration"/>
<resource name="view" type="velocity" location="templates/issue-check-point.vm"/>
</web-panel>
The Java class is :
@Scanned
public class IssueCheckPointsConfiguration extends AbstractJiraContextProvider {
@Override
public Map<String, Object> getContextMap(ApplicationUser applicationUser, JiraHelper jiraHelper) {
Map<String, Object> contextMap = new HashMap<>();
List<IssueCheckPointConfiguration> issueCheckPointConfigurationList = null;
try {
System.out.println("###############$$$$$$$$$$$$ IssueServlet getContextMap() $$$$$$$$$$$$$$#################");
Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue");
String currentIssueType = currentIssue.getIssueType().getName();
String currentStatusType = currentIssue.getStatus().getName();
boolean saveIssueConfig = false;
contextMap.put("issueCurrentStatus", issueCurrentStatus);
}
Can you please advise me on where the issue is or how this can be resolved in the case when saving the configuration
http://localhost:2990/jira/projects/TEST/issues/TEST-2?filter=allopenissues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would like to know how to fetch the linked ticket details. Below is the code i am using,
public class IssueCheckPointsConfiguration extends AbstractJiraContextProvider {
@Override
public Map<String, Object> getContextMap(ApplicationUser applicationUser, JiraHelper jiraHelper) {
Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue");
String currentIssueType = currentIssue.getIssueType().getName();
}
I would like to know if there is any option to get the linked ticket details from the Issue class.
Is there any way i can get the details from the database, by accessing data from some table.If so please share the table name. I could only identify "jiraissue" table which contains the issue details, but the linked issue details i am not able to get.
Please help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk This is a question from myend - I have a similar issue, to pass the data from the vm file to a Java Class.
Please help me with some code snippet on how can this be archive or any documentation which i can refer.
My UI looks is attached along.
My requirement is on clicking create button, the checkpoints filed, status field data and remarks field data should be fetched to the Java class
My VM file looks like this:
<style type="text/css">
.init-template-div {
margin-left: 5px;
border: 1px dashed #ccc;
border-radius: 0;
padding: 7px;
transition: background-color 0.01s linear 0.01s;
position: relative;
text-align: center;
}
.init-template-div > div {
padding: 4px 0;
}
</style>
<div id="issue-left" class="module toggle-wrap">
<div id="issue-left_heading" class="mod-header">
<ul class="ops"></ul><a href="#" class="aui-button toggle-title">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14"><g fill="none" fill-rule="evenodd"><path d="M3.29175 4.793c-.389.392-.389 1.027 0 1.419l2.939 2.965c.218.215.5.322.779.322s.556-.107.769-.322l2.93-2.955c.388-.392.388-1.027 0-1.419-.389-.392-1.018-.392-1.406 0l-2.298 2.317-2.307-2.327c-.194-.195-.449-.293-.703-.293-.255 0-.51.098-.703.293z" fill="#344563"></path></g></svg></a>
<!--<h4 class="toggle-title">Configuration CheckLists</h4>-->
</div>
<div class="mod-content">
<div class="table-issue-panel ghx-container" data-nocache="1588788605635" id="elements-ISSUE">
<div data-reactroot="" style="background-color: white;">
<div id="95s1rtdyf" class="module">
<div class="panelHeaderTitleServer mod-header">
<b class="panel-title-label collapse-panel">
<span class="aui-iconfont-arrow2-down aui-icon aui-icon-small "></span>
</b>
<form class="aui top-label" style="margin-top: 15px;" action="/saveCheckPoints">
<fieldset class="top-label">
<div class="field-group top-label">
<label for="generatedNodeId-15">Check Points</label>
<select name="globalConfigurationDetails" id="globalConfigurationDetails"
class="text auiTextInput">
<option value="-1">--Select Issue Types--</option>
#foreach( $globalConfigurationDetails in $globalConfigurationDetailsList )
<option value="$globalConfigurationDetails" >$globalConfigurationDetails</option> #end
</select>
</div>
<div class="field-group top-label">
<label for="generatedNodeId-15">Status</label>
<select name="status" id="status"
class="text auiTextInput">
<option value="-1">-Select Status-</option>
<option value="YES" >YES</option>
<option value="NO" >NO</option>
<option value="NA" >NA</option>
</select>
</div>
<div class="field-group top-label"><label for="issue_panel_new_element47ujln567">Remark</label>
<input type="text" id="remarks" name="remarks" class="text auiTextInput long-field" value="">
</div>
</fieldset>
</form>
</div>
</div>
<span class="issue-form-actions"><button class="aui-button aui-button-compact marginRight" aria-disabled="false">Create</button><a id="1dm5gbplj" href="#" class="actionLink ">Cancel</a></span>
</div>
</div>
</div>
</div>
My Java class is as below,
package com.example.plugins.tutorial;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.customfields.CustomFieldType;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.sql.Date;
import java.time.format.TextStyle;
import java.util.Locale;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import com.atlassian.plugins.tutorial.objects.CustomFieldNames;
import static java.time.temporal.ChronoUnit.DAYS;
import com.atlassian.plugins.tutorial.utils.DBUtils;
import com.atlassian.plugins.tutorial.objects.GlobalConfigurationDetails;
public class DueDateIndicator extends AbstractJiraContextProvider {
@Override
public Map<String, Object> getContextMap(ApplicationUser applicationUser, JiraHelper jiraHelper) {
Map<String, Object> contextMap = new HashMap<>();
Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue");
String currentIssueType = currentIssue.getIssueType().getName();
String currentStatusType = currentIssue.getStatus().getName();
/**
* Logic to fetch the Configuration based on the issue typeand status.
*/
List<String> globalConfigurationDetailsList = new ArrayList<String>();
globalConfigurationDetailsList = DBUtils.filterGlobalConfigurationDetails(currentIssueType, currentStatusType);
contextMap.put("globalConfigurationDetailsList", globalConfigurationDetailsList);
return contextMap;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Actually you can pass data from Java to vm file but you can only pass data from vm to Java via servlets and using html form in vm file.
If you define a servlet to listen saveCheckPoints then you can get those form parameters using HttpRequest's request.getParameter("remarks") methods.
Am I missing anything?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk Thanks for sharing your valuable comments.
To give more idea on what my requirement is , i am using 2 plugin module here web-item, web-panel
From the web-item i am doing the configuration part like adding configuration values for the CheckPOINT field.
From the pluggin module web-panel , it displays the configured values in dropdown when a issue is taken and user have the option to select values and savealong with remarks. I am stuck at this point. Nothing is working for me to fetch the selected checkpoint and remarks to the Java class.
I hope you have got a clear picture on my requirement.
As suggested When i converted to html file the UI changed as below,
I will share my atlassian-pluggin.xml so that you will understand how i have generated the screen
<?xml version="1.0" encoding="UTF-8"?>
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}"/>
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="tutorial-jira-add-content-to-view-issue-screen"/>
<!-- add our web resources -->
<web-resource key="tutorial-jira-add-content-to-view-issue-screen-resources" name="tutorial-jira-add-content-to-view-issue-screen Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="tutorial-jira-add-content-to-view-issue-screen.css" location="css/tutorial-jira-add-content-to-view-issue-screen.css"/>
<resource type="download" name="tutorial-jira-add-content-to-view-issue-screen.js" location="js/tutorial-jira-add-content-to-view-issue-screen.js"/>
<resource type="download" name="xproduct-admin-ui-plugin.css" location="css/xproduct-admin-ui-plugin.css"/>
<resource type="download" name="xproduct-admin-ui-plugin.js" location="js/xproduct-admin-ui-plugin.js"/>
<resource type="download" name="images/" location="/images"/>
<context>tutorial-jira-add-content-to-view-issue-screen</context>
</web-resource>
<web-panel name="DueDateIndicator" i18n-name-key="due-date-indicator.name" key="due-date-indicator" location="atl.jira.view.issue.left.context" weight="1000">
<description key="due-date-indicator.description">The DueDateIndicator Plugin</description>
<context-provider class="com.example.plugins.tutorial.DueDateIndicator"/>
<resource name="view" type="velocity" location="templates/due-date-indicator.vm"/>
<label key="due-date-indicator.title"/>
</web-panel>
<!-- <web-panel name="DurationIndicator" i18n-name-key="due-date-indicator.name" key="duration-indicator" location="atl.jira.view.issue.right.context" weight="1000">
<description key="Nothing">The Duration Indicator</description>
<context-provider class="com.example.plugins.tutorial.DurationIndicator"/>
<resource name="view" type="velocity" location="templates/duration-indicator.vm"/>
</web-panel>-->
<servlet key="admin-servlet" class="com.atlassian.plugins.tutorial.globalConfig.AdminServlet">
<url-pattern>/globalConfig/admin</url-pattern>
</servlet>
<web-item name="Global Configuration" i18n-name-key="global-configuration.name" key="global-configuration" section="system.admin/globalsettings" weight="1000">
<description key="global-configuration.description">The Global Configuration Plugin</description>
<label key="global-configuration.label"></label>
<link linkId="global-configuration-link">/plugins/servlet/globalConfig/admin</link>
</web-item>
</atlassian-plugin>
I have tried used @RequestMapping and injected the dependecy in pom file.
After that in the <form> tag of vm file i set as
<form class="aui top-label" style="margin-top: 15px;" action="/saveConfigDetails">
But the control is not coming to the particular method in Java class.
@RequestMapping(value = "/saveConfigDetails", method = RequestMethod.GET)
public void saveConfigDetails() {
System.out.println(" ****************** saveConfigDetails GET ***************** ");
}
I am sure some were i missed some thing....Please help on how this can be resolved.If there is a better solution plz suggest.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are two ways to pass request parameters to the server side (your Java class)
public class MyServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String value = req.getParameter("my-form-parameter");
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk Great Thanks for your reply.
I had done some analysis and was able to bring in the usage of the
HttpServletRequest request = jiraHelper.getRequest(); in the contextMap() method.So from this request i am able to fetch the UI vlues like remarks/status.
Also i had referred your comment in https://community.atlassian.com/t5/Answers-Developer-Questions/Method-getValueFromIssue-called-multiple-times/qaq-p/466652
which avoid the multiple call issue when the page is getting loaded.
Thanks for that too..
As part of improvement i require support and suggestion from your end : Currently when the create button is clicked, the data is getting saved and getting display.But the page is getting reloaded.Is there any way i can use Ajax or Jquery to call the getContextmap() method or any other custom method in another java class.
If its possible can you please share the code snippet of the call done in the VM file and how the java class should be designed.
Thanking you in advance...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Haha, I hate that hitting multiple times problem, I hope it helps.
Of course you can also implement a REST endpoint and use it in your vm file in order to pass client parameters to the server side.
Below I tried to add a snippet. But first you need to implement rest modeule which I already mentioned in my previous comment above.
I hope below code snippet helps
<script type="text/javascript">
AJS.$("#my-button-id").click(function (e) {
e.preventDefault();
doAjax();
});
function doAjax() {
jQuery.ajax({
type: "POST",
url: "${baseUrl}/rest/my-rest-api/1.0/my-service",
dataType: 'json',
contentType: 'application/json',
data: data
}).done(function (msg) {
});
}
</script>
Tuncay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk Thanks for the reply.
Can you please share the documentation for implementing a REST endpoint.
Also i have another requirement. As in the above screen shot , when i click on the create button the data is getting save to the DB and its getting displayed in the table grid.
But i could see that in the URL the parameters are getting appended, even after saving the data and the page reload happens.
Example : http://localhost:2990/jira/browse/TEST-6?checkPoint=Task+is+Done.Close+it.&status=YES&remarks=sss
Is there any way to remove
?checkPoint=Task+is+Done.Close+it.&status=YES&remarks=sss
from the URL after the page reload.
Thanks in Advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should change form method to POST in vm file.
Here is the link to rest-module : https://developer.atlassian.com/server/framework/atlassian-sdk/rest-plugin-module
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you're very welcome
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.