I have a select field whose values I need in the Java file, so how can i pass the current selected value from velocity to java file
Community moderators have prevented the ability to post new answers.
Ashish
If you want to pass calue from velocity to webwork action class you need to do the below
1. In the velocity have the html element name eg : <select name= myParameterName >
(This is just a psuedo code)
2. In your java class declare a private variable
Private String myParameterName;
As you must have observed the name is same in velocity file and java file.
3. Now create getter and setter methods in your java class
String getMyParameterName(){
Return myParameterName;
}
Void setMyParameterName(String myParameterName){
myParameterName=myParameterName;
}
Now when on submit from velocity when you call this action the parameters are available using getMyParameterName()
This is feature of webwork. Similarly multiple parameters can be accessed in the action class.
Hope this helps
The submit action url as set above redirects me to a different page which appears to be dead. How can I stay on the same page and perform the action without being redirected @Mizan .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The submit action url redirects me to different page which says dead page how can I have the action url set to stay on the same page
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
If your velocity is not for validators, conditions, webworks and so on, then you would need to execute a rest call to pass parameters from a velocity template.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My Template File looks like:-
<select id="parent" name="parent_version">
<option selected="selected" value="CONF">Confluence</option>
<option value="JIRA">JIRA</option>
<option value="JAG">JIRA Agile</option>
<option value="CAP">JIRA Capture</option>
<option value="AUI">AUI</option>
</select>
My java file looks Like:-
class Outer extends JiraContextProvider{
class Inner extends JiraWebActionSupport {
public String doExecute(){}
}}
So I have to make a rest call from the velocity to the doExecute method ?
Could you please help me with any sample code so that i can have a crystal clear understanding how the communication will work ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexey Matveev I have made the post call from the velocity passing the data within it, but I am not clear how are we going to catch and use it in the inner class method.
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.
I gave you general ideas. Unfortunately, I do not have time to make your code work.
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.
@Alexey Matveev I am making use of the Webwork to pass values but unfortunately that is not working.
xml :-
<webwork1 key="passValue" name="Quick Create User Issue" class="java.lang.Object">
<actions>
<action name="com.example.plugins.tutorial.DueDateIndicator" alias="DueDate">
<view name="stayhere">\templates\due-date-indicator.vm</view>
</action>
</actions>
</webwork1>
velocity :-
<form class="aui" name="input" action="http://localhost:2990/jira/secure/DueDate.jspa" method="post">
<select id="parent" name="execute" >
<option selected="selected" value="CONF">Confluence</option>
<option value="JIRA">JIRA</option>
<option value="BAM">Bamboo</option>
<option value="JAG">JIRA Agile</option>
<option value="CAP">JIRA Capture</option>
<option value="AUI">AUI</option>
</select>
<input type="submit">
</form>
java :-
class Outer extends AbstractJiraContextProvider {
class Inner extends JiraWebActionSupport {
public String doExecute(){
String[] vals = request.getParameterValues("val");
return vals[0];
}
Inner inner = new Inner()
inner.doExecute()
}
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.
Community moderators have prevented the ability to post new answers.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.