You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emi Lu <em...@encs.concordia.ca> on 2011/08/11 17:16:00 UTC

how to make onchange in s:select to submit a form and call a specific method in one action class

Good morning,

In struts2.2.3, how to submit a form to a predefined action?

For example,

(1) a.jsp
<s:select onchange="changeProcess" />

(2) Process.java
...
public String change()
{
    get Form values from a.jsp
    database actions ... ...
    return a.jsp;
}


I'd like to know:
===========================
When values changed in s:select, how to submit the form and call 
change() method in Process.java

Thanks lot!
Emi




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: how to make onchange in s:select to submit a form and call a specific method in one action class

Posted by Marcus Bond <ma...@marcusbond.me.uk>.
You could always make your own tag as an extension to the standard struts select tag adding attributes onChangeAction and onChangeTarget and let your new tag render an appropriate bit of javascript to make an ajax call to the server and then populate the results into the target item.. such a set of tags in your jsp may look like
<myTagLib:select name="country" onchangeAction="regionsForCountry" onChangeTarget=" region" />
< myTagLib:select name="region"  onchangeAction="countiesForRegion" onChangeTarget=" county"   />
< myTagLib:select name="county"   />

This would be a handy feature in a new struts tag to be fair, perhaps an <s:dynamicSelect>...

Marcus

-----Original Message-----
From: Christian Grobmeier [mailto:grobmeier@gmail.com] 
Sent: 11 August 2011 16:41
To: Struts Users Mailing List; emilu@encs.concordia.ca
Subject: Re: how to make onchange in s:select to submit a form and call a specific method in one action class

> Or someone could provide more info will "sj:select" help satisfy the 
> following requirement?
>
> (1) <sj:select name="country" onchange="to_change_region" />
> (2) <sj:select name="region"  onchange="to_change_city"   />
> (3) <sj:select name="coutry"   />
>
> Actually, I prefer not to use complex javascript code to do change 
> select1,
> select2 is updated, change select2, and select3 is updated.

No chance without javascript. There is no struts on board functionality providing that feature.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how to make onchange in s:select to submit a form and call a specific method in one action class

Posted by Christian Grobmeier <gr...@gmail.com>.
> Or someone could provide more info will "sj:select" help satisfy the
> following requirement?
>
> (1) <sj:select name="country" onchange="to_change_region" />
> (2) <sj:select name="region"  onchange="to_change_city"   />
> (3) <sj:select name="coutry"   />
>
> Actually, I prefer not to use complex javascript code to do change select1,
> select2 is updated, change select2, and select3 is updated.

No chance without javascript. There is no struts on board
functionality providing that feature.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how to make onchange in s:select to submit a form and call a specific method in one action class

Posted by Emi Lu <em...@encs.concordia.ca>.
Hello,

> The onchange attribute expects JavaScript.  So you'd have to write a
> function to use ajax to make your request to /process_change.action.

Or someone could provide more info will "sj:select" help satisfy the 
following requirement?

(1) <sj:select name="country" onchange="to_change_region" />
(2) <sj:select name="region"  onchange="to_change_city"   />
(3) <sj:select name="coutry"   />

Actually, I prefer not to use complex javascript code to do change 
select1, select2 is updated, change select2, and select3 is updated.

Thanks a lot!
Emi



>> In struts2.2.3, how to submit a form to a predefined action?
>>
>> For example,
>>
>> (1) a.jsp
>> <s:select onchange="changeProcess" />
>>
>> (2) Process.java
>> ...
>> public String change()
>> {
>>      get Form values from a.jsp
>>      database actions ... ...
>>      return a.jsp;
>> }
>>
>>
>> I'd like to know:
>> ===========================
>> When values changed in s:select, how to submit the form and call
>> change() method in Process.java
>>
>> Thanks lot!
>> Emi
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


-- 
Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
emilu@encs.concordia.ca        +1 514 848-2424 x5884

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: how to make onchange in s:select to submit a form and call a specific method in one action class

Posted by "Biesbrock, Kevin" <Bi...@aoins.com>.
The onchange attribute expects JavaScript.  So you'd have to write a
function to use ajax to make your request to /process_change.action.

---
d[-_-]b
Beez

> -----Original Message-----
> From: Emi Lu [mailto:emilu@encs.concordia.ca] 
> Sent: Thursday, August 11, 2011 11:16 AM
> To: Struts Users Mailing List
> Subject: how to make onchange in s:select to submit a form 
> and call a specific method in one action class
> 
> Good morning,
> 
> In struts2.2.3, how to submit a form to a predefined action?
> 
> For example,
> 
> (1) a.jsp
> <s:select onchange="changeProcess" />
> 
> (2) Process.java
> ...
> public String change()
> {
>     get Form values from a.jsp
>     database actions ... ...
>     return a.jsp;
> }
> 
> 
> I'd like to know:
> ===========================
> When values changed in s:select, how to submit the form and call
> change() method in Process.java
> 
> Thanks lot!
> Emi
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org