• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Issue in Struts Dropdown(Need Help Ranchers)

 
Ranch Hand
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Deepak Lal
Ranch Hand
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me with this issue.
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could you post your entire ActionForm class?
 
Deepak Lal
Ranch Hand
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The problem lies within jsp.can you modify the jsp and tell me where it is wrong.???
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic