Get info from webwork action form

I have a web-work action which is loading perfectly in a dialog box,
I’m using the doDefault to initialize many parameters am using in the vm , however once submitted it appears that the doExecute of my class (that extends JiraWebActionSupport) is not being called.

My main need is to get the info submitted from the form into the class and do some work there, my only other option is a REST call that I’m trying to avoid if there’s a solution with this one.

Any help on this?

Hi Christian,

as far as I understand your problem, a REST Call is not needed. Your HTML form inside your VM calls your function “doExecute” for example by:

yourActionClass!execute.jspa

Please note, that you have to use “execute” and not “doExecute”. First letter has to be lower case, even yours is upper case. Then, you just have to declare getter and setter in your class for each textfield or whatever you have declared in your HTML form. If your textbos is named as “myTextbox”, then your setter must be named as “setMyTextbox”.

After that, your function “doExecute” will be called and at the time it is called, every form parameter is already be set and ready for your use.

Kind regards.

Thanks miessner for the clarification!

@m.miessner

However how can I load my jspa with a doDefault (!default) then on form submission have it !execute for it to execute doExecute??
It’s unclear to me as my link for the dialog now is something like this:
href="/secure/CreateSomething!default.jspa?issueId=$issue.id"

You are on the right way. :slight_smile:

Try to use

href="/secure/CreateSomething!execute.jspa?issueId=$issue.id"

to call your “doExecute” function in your “CreateSomething” class.

But will it call doDefault first to initialize the variables that are used in the vm?

No, not “doDefault” but, you can access all your parameters if they have a setter/getter function in your class. That means:

In your example, you are dealing with “issueId” as parameter. Please add the following code to your class:

    public void setIssueId(long NewValue)
    {
        lng_IssueId = NewValue;
    }

Declare “lng_IssueId” in your class header. Then, inside of “doExecute” you have full access to “lng_IssueId”, because the setter is indead called before your doExecute is called. :slight_smile:

Please be aware of upper/lower case in the set function. It is very important.

Yes indeed, this is already done to access issueId!
My question is more about this:
I have an Arraylist that I’m populating currently at the level of doDefault to populate the form on rendering. This is done as I understand now, because am calling !default, so my concern is that if I’m calling !execute, how will I have these lists populated for at first the rendering of my form? How can I make it still with !default but just on submission call !execute ?

Thanks a lot for your follow-up!

What about to pre-initialize your Array in the class constructor? Save it in a private variable which is accessable by a public get function. These get function is every time accessable inside of your vm file by the ${} syntax. So, if I understand correctly, it is not important if you call “doExecute” or “doDefault” because your variable is always set.

As I understand you’re triggering a form dialog with href="/secure/CreateSomething!default.jspa?issueId=$issue.id".

All you need to do is to set the forms action attribute to CreateSomething.jspa and it’ll hit doExecute() with form values when form is submitted

<form action="CreateSomething.jspa" method="post"></form>