File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data loading problem in select tag using ajax in struts2

 
sam raghav
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I am new to struts. I have some code like this.

registration.jsp
------------------
<body onload = "doRequestGETState(' StateAction?stateBn.state= ' + '');">
<span id = "inp" />
</body>

registrationInput.jsp
<s:fielderror/>
<s:actionerror/>

<s:select name="regBn.stateId" list="stateList" cssStyle="width: 180px;"
title="State" tabindex="1" onchange="doRequestGETState(' StateAction?stateBn.state=' + this.value); "
listValue="stateName" listKey="stateId" value="stateBn.state" headerKey=""
headerValue="Select State"/>

<s:select name="regBn.city" list="cityList" cssStyle="width: 180px;" title="City" tabindex="1"
listValue="cityName" listKey="cityId" headerKey="" headerValue="Select City" />


struts.xml
--------------
<action name="StateAction" class="com.iMovers.res.action.StateAction">
<result name="success">/registrationInput.jsp</result>
</action>

<action name="RegistrationAction" class="com.iMovers.res.action.RegistrationAction">
<result name="input">/registrationInput.jsp</result>
</action>


Problem is on validating registrationInput.jsp and coming back to registrationInput.jsp I am getting error

"The requested list key 'stateList' could not be resolved as a collection/array/map/enumeration/iterator type."

If I will change the result name from registrationInput.jsp to registration.jsp then I can not display error message.

Please let me know If there is any way to come out of it.

Thanks and regards
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actions are instantiated per-request: the collection still needs to exist for the collection to be displayed.
 
sam raghav
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

Yes I know it is session less and server has to ping again before displaying the collections. But if I ping the server then I will lost the error messages.

Is there any way to come out of it.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either keep the list in session or application context, re-generate it, or use the message store interceptor to keep the messages across the requests.
 
sam raghav
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the continuous support.
Please give me a example. That will be more helpful for me.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example of what? Putting a variable into a scope? Creating a collection? Using the message store interceptor?
 
sam raghav
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David thanks for your continuous support.
I have used Message Store Interceptor. But after using that I am able to reclaim the message wherever I want but because of this I loses all the current request attributes.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not *because* of the message store interceptor. You're losing request attributes because you're making another request.
 
sam raghav
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I have given in first post, I am using ajax to fill dependent select box,

-----------------------------------
<body onload = "doRequestGETState(' StateAction?stateBn.state= ' + '');">
<span id = "inp" />
</body>
------------------------------------

so, request will go automatically when it will forwarded to registration.jsp.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic