You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by chumbobumbo <ch...@hotmail.com> on 2009/03/02 00:47:12 UTC

Struts Ajax Newbie

This is probably so basic - I'll put my flame proof suit just in case.

I have a 2 combos and (yes ;-) I would like the second one to be loaded
depending on what's been chosen in the first one, so in my action execute
method I have:

     model.setList(service.getData1());

my struts.xml looks like this (note that I am using spring and I am hitting
the same action 'class' (demoAction):

               <action name="firstAction" class="demoAction"
method="execute">
			<result name="success">jsp/output.jsp</result>
			<result name="error">jsp/error.jsp</result>
		</action>
		<action name="secondAction" class="demoAction" method="second">
			<result name="success">jsp/second.jsp</result>
			<result name="error">jsp/error.jsp</result>
		</action>

in my output jsp I have:

.....

    <td><s:select list="model.list" listKey="entry.code"
listValue="entry.desc"  name="selection.listCode"
   				onchange="javascript:load_second_list();return
false;"></s:select></td>
		</tr>

		<tr>
			<td>
   				<s:url id="second_url" action="loadSecond.action" /> 
   				<s:div showLoadingText="false" id="second" href="%{second}"
theme="ajax"
   					listenTopics="load_second_list" formId="demo"/>
			</td>
		</tr>

that's all fine and dandy, but when I call loadSecond.action I find that my
model is re-initialised anew (i.e. as the action is marked 'prototype' in
spring config, the data for the first combo is no longer there) 

obviously I need data in the 1st combo to be available in the resulting
page, as the user should be allowed to change the first selection (that
would in turn relaod the second combo again). 

Is there a way to serialize/cache the data that was retrieved in the first
call so that it is available in the subsequent call other than putting it in
the session?

Thanks,

99-L Blue 
-- 
View this message in context: http://www.nabble.com/Struts-Ajax-Newbie-tp22279792p22279792.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts Ajax Newbie

Posted by chumbobumbo <ch...@hotmail.com>.
Thanks for your help, however I think I may have miscommunicated, all I was
trying to find out is what is the 'currently acceptable' approach for
storing (and retrieveing) data between consecutive ajax calls seeing that
one always gets a brand new instance for any (and every) given action. Does
Struts provide some kind of mechanism other than http sesison to store
dependant data?

Thanks

99-L Blue



Mileidys Gonzalez Prieto wrote:
> 
> Well, for to do actions like that in my code I'm using AjaxTags.
> 
> http://ajaxtags.sourceforge.net/
> 
> Is really easy to use...
> 
> On Sun, 2009-03-01 at 15:47 -0800, chumbobumbo wrote:
>> This is probably so basic - I'll put my flame proof suit just in case.
>> 
>> I have a 2 combos and (yes ;-) I would like the second one to be loaded
>> depending on what's been chosen in the first one, so in my action execute
>> method I have:
>> 
>>      model.setList(service.getData1());
>> 
>> my struts.xml looks like this (note that I am using spring and I am
>> hitting
>> the same action 'class' (demoAction):
>> 
>>                <action name="firstAction" class="demoAction"
>> method="execute">
>> 			<result name="success">jsp/output.jsp</result>
>> 			<result name="error">jsp/error.jsp</result>
>> 		</action>
>> 		<action name="secondAction" class="demoAction" method="second">
>> 			<result name="success">jsp/second.jsp</result>
>> 			<result name="error">jsp/error.jsp</result>
>> 		</action>
>> 
>> in my output jsp I have:
>> 
>> .....
>> 
>>     <td><s:select list="model.list" listKey="entry.code"
>> listValue="entry.desc"  name="selection.listCode"
>>    				onchange="javascript:load_second_list();return
>> false;"></s:select></td>
>> 		</tr>
>> 
>> 		<tr>
>> 			<td>
>>    				<s:url id="second_url" action="loadSecond.action" /> 
>>    				<s:div showLoadingText="false" id="second" href="%{second}"
>> theme="ajax"
>>    					listenTopics="load_second_list" formId="demo"/>
>> 			</td>
>> 		</tr>
>> 
>> that's all fine and dandy, but when I call loadSecond.action I find that
>> my
>> model is re-initialised anew (i.e. as the action is marked 'prototype' in
>> spring config, the data for the first combo is no longer there) 
>> 
>> obviously I need data in the 1st combo to be available in the resulting
>> page, as the user should be allowed to change the first selection (that
>> would in turn relaod the second combo again). 
>> 
>> Is there a way to serialize/cache the data that was retrieved in the
>> first
>> call so that it is available in the subsequent call other than putting it
>> in
>> the session?
>> 
>> Thanks,
>> 
>> 99-L Blue 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-Ajax-Newbie-tp22279792p22281426.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts Ajax Newbie

Posted by Mileidys Gonzalez Prieto <mi...@i-frontier.net>.
Well, for to do actions like that in my code I'm using AjaxTags.

http://ajaxtags.sourceforge.net/

Is really easy to use...

On Sun, 2009-03-01 at 15:47 -0800, chumbobumbo wrote:
> This is probably so basic - I'll put my flame proof suit just in case.
> 
> I have a 2 combos and (yes ;-) I would like the second one to be loaded
> depending on what's been chosen in the first one, so in my action execute
> method I have:
> 
>      model.setList(service.getData1());
> 
> my struts.xml looks like this (note that I am using spring and I am hitting
> the same action 'class' (demoAction):
> 
>                <action name="firstAction" class="demoAction"
> method="execute">
> 			<result name="success">jsp/output.jsp</result>
> 			<result name="error">jsp/error.jsp</result>
> 		</action>
> 		<action name="secondAction" class="demoAction" method="second">
> 			<result name="success">jsp/second.jsp</result>
> 			<result name="error">jsp/error.jsp</result>
> 		</action>
> 
> in my output jsp I have:
> 
> .....
> 
>     <td><s:select list="model.list" listKey="entry.code"
> listValue="entry.desc"  name="selection.listCode"
>    				onchange="javascript:load_second_list();return
> false;"></s:select></td>
> 		</tr>
> 
> 		<tr>
> 			<td>
>    				<s:url id="second_url" action="loadSecond.action" /> 
>    				<s:div showLoadingText="false" id="second" href="%{second}"
> theme="ajax"
>    					listenTopics="load_second_list" formId="demo"/>
> 			</td>
> 		</tr>
> 
> that's all fine and dandy, but when I call loadSecond.action I find that my
> model is re-initialised anew (i.e. as the action is marked 'prototype' in
> spring config, the data for the first combo is no longer there) 
> 
> obviously I need data in the 1st combo to be available in the resulting
> page, as the user should be allowed to change the first selection (that
> would in turn relaod the second combo again). 
> 
> Is there a way to serialize/cache the data that was retrieved in the first
> call so that it is available in the subsequent call other than putting it in
> the session?
> 
> Thanks,
> 
> 99-L Blue 


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


Re: Struts Ajax Newbie

Posted by mitch gorman <mg...@shadowtv.biz>.
chumbobumbo wrote:
> This is probably so basic - I'll put my flame proof suit just in case.
>
> I have a 2 combos and (yes ;-) I would like the second one to be loaded
> depending on what's been chosen in the first one, so in my action execute
> method I have:
>   

    take a look at <s:doubleselect>.


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