Ideally for a select box, u should get lable and correspoding value from the bean.. ur bean shld be something like this..
put the Editors in the session or request obj.. get it in JSP.. JSP code ...
hope that helps!!
MT
JiaPei Jen
Ranch Hand
Joined: Nov 19, 2000
Posts: 1309
posted
0
Thanks for your help. May I ask two questions? Q1.
EDITORS is the session object; i.e. session.setAttribute("EDITORS", editors);. What is 'id' in the <bean:define ....../> tag? Q2.
Is it possible to specify the <htmlptions ..../> tag without labelProperty? I must go to the database to find a value to populate the bean and there is only one property in the bean. [ November 29, 2003: Message edited by: JiaPei Jen ] [ November 29, 2003: Message edited by: JiaPei Jen ]
manasa teja
Ranch Hand
Joined: May 27, 2002
Posts: 325
posted
0
What is 'id' in the <bean efine ....../> tag its a scriptying varibale.. you have to declare that to get the "EDITORS" from the session into JSP --- If your label and value are one and the same... then, whatever u posted in ur fisr post is correct... that is
then in JSP just do this!!
hope that helpS [ November 30, 2003: Message edited by: manasa teja ]
JiaPei Jen
Ranch Hand
Joined: Nov 19, 2000
Posts: 1309
posted
0
I tried
But, got an error message: org.apache.jasper.JasperException: Cannot retrieve definition for form bean null I tried another way:
The error message is the same. I do not have a form. Why the error message is "cannot retrieve definition from form bean null"? Because the editors is a Collection. The editors is also an ArrayList of EditorBean(s), editors is passed to my JSP in a session object.
Do I have to retrieve editors from the session object in my JSP? How do I retriever a Collection from a session object? [ December 01, 2003: Message edited by: JiaPei Jen ]
manasa teja
Ranch Hand
Joined: May 27, 2002
Posts: 325
posted
0
Originally posted by JiaPei Jen: I tried
But, got an error message: org.apache.jasper.JasperException: Cannot retrieve definition for form bean null I tried another way:
The error message is the same. I do not have a form. Why the error message is "cannot retrieve definition from form bean null"? Because the editors is a Collection. The editors is also an ArrayList of EditorBean(s), editors is passed to my JSP in a session object.
Do I have to retrieve editors from the session object in my JSP? How do I retriever a Collection from a session object? [ December 01, 2003: Message edited by: JiaPei Jen ]
yes u have to retrive the arraylist into ur JSp from session. it is like this <bean efine id="editorsList" name="EDITORS" scope="session" type="java.util.ArrayList" /> then.. html:select tag.. Try this.. it should work
JiaPei Jen
Ranch Hand
Joined: Nov 19, 2000
Posts: 1309
posted
0
I tried:
I got: HTTP Status 500 - org.apache.jasper.JasperException: Cannot retrieve definition for form bean null [ December 02, 2003: Message edited by: JiaPei Jen ]
Try this, session.setAttribute( "editors", editors ); <html:form action="/Save" name="myForm" type="com.ctg.dspv.services.admLegalPerson.CreateUpdateForm" scope="session"> <html:select name="myForm" property="editorName"> <html ptions collection="editors" property="name" labelProperty="name"/> </html:select> </html:form> ActionForm => com.ctg.dspv.services.admLegalPerson.CreateUpdateForm with a getter and setter for editorName
manasa teja
Ranch Hand
Joined: May 27, 2002
Posts: 325
posted
0
Originally posted by JiaPei Jen: I tried:
I got: HTTP Status 500 - org.apache.jasper.JasperException: Cannot retrieve definition for form bean null [ December 02, 2003: Message edited by: JiaPei Jen ]
I am not sure abt the problem,.. but, plase check this.. 1) have you declared the selectbox name in form bean.. 2)See, whether, session attrribute name and the name you are reffereein gin the JSP are one aand same..
JiaPei Jen
Ranch Hand
Joined: Nov 19, 2000
Posts: 1309
posted
0
Nathalie, thank you very much. I tried what you suggested and I was able to disply the drop-down list. Manasa, I also appreciate your support very much. You have helped me to understand a bit more about strusts form tag, select tag, and how to display an ArrayList that is passed to a JSP in a session object.