File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Issue in Struts Dropdown(Need Help Ranchers) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Issue in Struts Dropdown(Need Help Ranchers)" Watch "Issue in Struts Dropdown(Need Help Ranchers)" New topic
Author

Issue in Struts Dropdown(Need Help Ranchers)

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

Hi Ranchers,
Im facing problems with my dropdown list population in Struts 1.x version.

Please find the below code.I need your help ranchers to resolve this problem.




Please tell me how should i populate the values from the list named "ListData" on to the jsp page i.e how should the Country Dropdown be populated
Please help me since i have been struggling to get this right.



When The Going Gets Tougher,The Tougher gets Going
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

Please help me with this issue.
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
could you post your entire ActionForm class?


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

Hi Siva,
Please find the code below....Please help me out since the error is pointed out in jsp page.



Could you please modify the jsp page so that i can get the correct output ....
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
This is the Action class i need ActionForm class and also Struts-config.xml to have good look into your problem
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507



The problem lies within jsp.can you modify the jsp and tell me where it is wrong.???
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Let me know what are you trying to display.

Name? or id?

By the way try to follow naming conventions when declaring Variable.

Use camelCase when the variable has more than one word or else start with lowercase letter if the variable name is singe word.




will display name as lable and id as value.

But why this statement lies outside while loop

m.setXYZDropDownList(XYZDropDownValues);
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

Hi Siva,

Please find my queries.


Let me know what are you trying to display.
Name? or id? ---> I want to display name



By the way try to follow naming conventions when declaring Variable. --- Ok got it



Use camelCase when the variable has more than one word or else start with lowercase letter if the variable name is singe word.






Will the above code which you have pasted work???

Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Deepak Lal wrote:Hi Siva,

Please find my queries.


Let me know what are you trying to display.
Name? or id? ---> I want to display name



By the way try to follow naming conventions when declaring Variable. --- Ok got it



Use camelCase when the variable has more than one word or else start with lowercase letter if the variable name is singe word.




[code]
But why this statement lies outside while loop
m.setXYZDropDownList(XYZDropDownValues);
The above statement is outside while loop because once my list is constructed i will set it into a Pojo object......Hope it clarifies -->Please correct me if im wrong.
XYZPOJO class has two attributes moduleid,XYZDropdownList.I do not know where you are setting the value for both of these attributes.
Then inside while loop you are retrieving first XYZPojo object and displaying module id(So it seems the POJO object has been initialized somewhere only with module id not with the XYZDropDownlist.Then you are constructing XYZDropDownlist by passing the id and module id as the attribute.So id will be stored in id and module id will be stored as name in the XYZDropDwonlist class.Now,if you want to assign value to the XYZDropdownList attribute of the POJO class then you should have that statement inside the while loop so that the Object is completly initalized with List attribute inthe POJO class.


Will the above code which you have pasted work???
May be. I still did not understand why do you have List attribute in your POJO class.

Let me know the full operation so that i can help you.
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

Hi Siva,

Requirement :i have told you that i need to assign a dropdown list to jsp page so what changes i need to do to my code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue in Struts Dropdown(Need Help Ranchers)
 
Similar Threads
My html:select is not working
java. lang. IllegalArgumentException: No Bean specified, help me to resolve
No getter method for property
Does validator can't work with html:options tag??
html:select