I have a velocity template page which contains list of entries and a button.On clicking the button i would like to open a page were i can add new entries which in-turn gets populated to the list.
Issue : On clicking the button, i could see the control is going to a Get Method in the Java class,but not able to obtain any values from the vm page . I will be able to open the new page based on the data passed from the velocity template page.
Please suggest what or were have i gone wrong.I had done various trials based on the comments in other quereis.
Below are the code snippet. I tried to call a function but the alert is not coming.But the related Java class is method is called, but the data from form is not obtained
VM File content
<html>
<head>
<title>$i18n.getText("xproduct.admin.label")</title>
<meta name="decorator" content="atl.admin" />
$webResourceManager.requireResource("com.atlassian.plugins.tutorial.tutorial-jira-add-content-to-view-issue-screen:resources")
</head>
< script type="text/javascript">
function validateField() {
alert("test")
}
</script>
<body>
<form id="admin" class="aui">
<div class="aui-page-panel">
<div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<div id="elements-admin-main">
<div data-reactroot="">
<div>
<h2>Global Configuration Checklist
<!-- <input type="submit" value="Create Global Config" class="aui-button aui-button-primary headerCreateBtn">-->
<input type="text" name="createField" value="create">
<button class="aui-button aui-button-primary headerCreateBtn" id="createGlobalConfig" onclick="validateField()">
Create</button>
</h2><hr>
</div>
<table class="aui">
<thead>
<tr>
<th>$i18n.getText("global.configuration.name")</th>
<th>Issue type(s)</th>
<th>Last update</th>
<th>Updated By</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
#foreach( $globalConfigurationDetails in $globalConfigurationDetailsList )
<tr>
<td>$globalConfigurationDetails.getConfigName()</td>
<td>$globalConfigurationDetails.getIssueType()</td>
<td>$globalConfigurationDetails.getUpdatedDate()</td>
<td>$globalConfigurationDetails.getUpdatedBy()</td>
<td><a target="_blank" href="">Edit</a></td>
</tr>
#end
</tbody>
</table>
</div>
</div>
</section><!-- .aui-page-panel-content -->
</div><!-- .aui-page-panel-inner -->
</div>
</form>
</body>
</html>
JAVA class snippet
@Scanned
public class AdminServlet extends HttpServlet
{
@ComponentImport
private final UserManager userManager;
@ComponentImport
private final LoginUriProvider loginUriProvider;
@ComponentImport
private final TemplateRenderer renderer;
@Inject
public AdminServlet(UserManager userManager, LoginUriProvider loginUriProvider, TemplateRenderer renderer)
{
this.userManager = userManager;
this.loginUriProvider = loginUriProvider;
this.renderer = renderer;
}
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
System.out.println("************************************ FROM PRODUCT PLUGIN ####################################");
System.out.println("************************************ Inside the GET Method........... @@@@@@@@@@@@@@@@@@@@@@@");
System.out.println("************************************ ************************************");
System.out.println("*************** ContextPath " +request.getContextPath());
//System.out.println("*************** Get Header " +request.getHeader());
System.out.println("*************** Path Info " +request.getPathInfo());
System.out.println("*************** Request URI " +request.getRequestURI());
System.out.println("*************** Servlet Path " +request.getServletPath());
System.out.println("*************** Request Get Attribute " +request.getAttribute("createField"));
Map<String, Object> context = new HashMap<String, Object> ();
String username = userManager.getRemoteUsername(request);
if (username == null || !userManager.isSystemAdmin(username))
{
redirectToLogin(request, response);
return;
}
List<GlobalConfigurationDetails> globalConfigurationDetailsList = new ArrayList<GlobalConfigurationDetails>();
globalConfigurationDetailsList = DBUtils.fetchGlobalConfigurationDetails();
context.put("globalConfigurationDetailsList", globalConfigurationDetailsList);
//Sample
/*
* Fetch data from DB
*/
// projectDetailsList = DBUtils.fetchProjectName();
System.out.println(" **************** Ïnside the Servelet :: projectDetailsList "+globalConfigurationDetailsList);
context.put("projectName", "Quality Engineering");
response.setContentType("text/html;charset=utf-8");
renderer.render("admin.vm", context, response.getWriter());
}
}
Community moderators have prevented the ability to post new answers.
Parameters can be accessed through "HttpServletRequest request" object you receive
See request.getParameter("createField") should give you the value "create"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alex Medved _ConfiForms_ 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 a single 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.
It feels like web development 101...
You can have a JavaScript inside your templates and have a client side validation. Or on submit you can have a validation on your servlet side.
I am a bit puzzled about your question - are you asking how to implement that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure I understand what you mean by "during transition". Is this about issue transition (from one state to another)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alex Medved _ConfiForms_ 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 accessing ticket via and 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.
Recommended Learning For You
Level up your skills with Atlassian learning
Learning Path
Apply agile practices
Transform how you manage your work with agile practices, including kanban and scrum frameworks.
Learning Path
Configure agile boards for Jira projects
Learn how to create and configure agile Jira boards so you can plan, prioritize, and estimate upcoming work.
Jira Essentials with Agile Mindset
Suitable for beginners, this live instructor-led full-day course will set up your whole team to understand how to use Jira with an agile methodology.
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.