Peixiao Lin

Greenhorn
+ Follow
since Oct 04, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Peixiao Lin

Merrill, as you mentioned above, I lost all erros message because of redirecting. Here is my validate() in ActionForm bean



in edit.jsp page,


I thought maybe I can save errors in session but not sure how to display ActionErrors stored in session? any suggestions? thanks again.
17 years ago
that works...thank you guys so much.
17 years ago
Thanks. One more question: where do I specify the forward name, which is gonna be used when validation fails somewhere? In action class?
17 years ago
Thanks for you reply, Merrill. I think the control flow even didn't reach the back-side action class. so I don't understand why you put a forward inside that action tag. In my opnion, it is the ActionServlet that invoke validate() on the form bean and stop submission if fails and then forward control to the path specified by the "input" property. So I think maybe redirect setting should be somewhere else?? just my 2 cents. thanks.
17 years ago
Hello, I am coding a project based on Struts and recently I got a problem caused by validation error. the work flow is that user input data in edit.jsp and then submit to back-side EditAction.java and then should be taken to review.jsp to review their input. Please refer to following information

in struts-config.xml: (baseForm is an ActionForm)


in edit.jsp:


The url for edit.jsp is "http://serverName/webroot/edit?param1=p1¶m2=p2". When I submit the form in edit.jsp, URL will become to "http://serverName/webroot/review.do" and being sent to server side. baseForm.validate() will be executed and catch invalid input if any, then return errors to edit.jsp page agaion and show user some error message. the problem is that upon validation failure, control returns to edit.jsp with changed URL, which is "http://serverName/webroot/review.do". Therefore, when I mean to refresh edit.jsp with its original url, it actually submit the form again. Is there any ways I can change url back upon validation failure? Thanks.
17 years ago
I thought it might be resolved by nested tag? Not sure, will do some research.
17 years ago
yeah, the question itself is confusing and I didn't ask in a clear way. I will try my best to clarify it. I am writing a table and trying to create rows dynamically.

<table>
<logic:iterate name="earth" property="northAmerican.countries" indexId="i" type="com.test.country">
<tr>
<td>
<html:select name="earth" property='<%="northAmerican.countries["+i+"].name"%>'/>
<html ptionsCollection name="options" property="countries">
</html:select>
</td>
</tr>
<tr>
<td>
<html:select name="earth" property='<%="northAmerican.countries["+i+"].state"%>'/>
<html ptionsCollection name="options" property="USA">
</html:select>
</td>
</tr>
</logic:iterate>
</table>

so here, "options" has a set of collections properties that represents all north american countries and all states for each countries. for example, countries is a collection of all coutries' names and USA is a collection of all states' name in the USA, and so on. "countries" is a list that has a set of country instance in it. Each "com.test.country" instance has name string and state string in it. User shoud be able to specify a country and a state in that country in this table. therefore, second selection list, which is states, will depend on first country choice. but the problem is how I can chcnage the property value in second <html ptionsCollection> tag instead of hardcode "USA"? or how I can pass the first choice value into that property attribute? please help.
17 years ago
that's right. The point here actually is how to dynamically change the property attribute value in <html ptionsCollection> tag. Any thoughts please? thanks.
17 years ago
Plus, if I use scriptlet here, I can not grab the index i into the scriptlet code. correct me if I am wrong. thanks
17 years ago
My bad...I am using JSP 1.2 so maybe I have to think about this problem differently. what about put some conditional tag between <html:select>..something like this

<html:select ...>
<logic:equal>
<html:optionsCollection ... />
</logic:equal>
</html:select>
17 years ago
I also tried to use <bean:write> tag as following



but this failed because of illegal quote nesting. any thoughts?
17 years ago
I create a selection list with Struts tag <html:select><html:optionsCollection>. But now the challenage is how to conditionally generate the optionsCollection? Please refer to following code:



In the code above, form is an ActionForm instance. bean is an instance binded in it. List is a set of instance, whose attribute of name will return a string used as optionsCollection's name. But this doesn't work to me. I thought the index i may not be in the same scope as the <c:out> tag?? please help.
[ February 13, 2007: Message edited by: Bear Bibeault ]
17 years ago
I wrote a simple javascript function to allow user to click for an new text line in JSP page A. Code is as following:

After this line is added, I go forward to next page B. When I click back button to go back to page A, the newly added line disappear. This problem only happens in IE. The IE version I am using is IE 7. Please advise. Thank you so much.
[ February 06, 2007: Message edited by: Bear Bibeault ]
I have a simple java bean class binded in an ActionForm, which is hooked up with a jsp page on front side. an input field in jsp page is a property of the bean class. for example, username or password. Now I want to use validator to validate user input. But inside validation.xml file, I don't know how to code the property value in <field> tag. Please see below. Normally the decleration shoud be like this

But since the username is binding in my bean class, so how do I code the property value? I tried followings but none works. or

Please help. Thank you so much.
17 years ago
Hello, I have a question about ActionForm. In struts-config.xml, I define my action mapping as following:


the page flow will go through init first, initiate a form instance, save it in session scope, go to InitFormAction, then forward to edit. Then..my question arised: May I change the form scope to request in edit? If I can, does it mean no form instance will be saved in session after summary.jsp?
17 years ago