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 Struts Select Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Select Tag" Watch "Struts Select Tag" New topic
Author

Struts Select Tag

sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
My action class setting an arrayobject in session.
ArrayList products = null;
try{
ProductProcessor pp = new ProductProcessor();
ProductBean pb = pp.getAllProductsByProductGroup();
products = pb.getProductNames();
}catch(PersistenceException pe){
;
}
session.setAttribute("products", products);
I want to populate the list in a dropdown using <html:select> tag.
Any one have simple example?.
When I placed this select tag it forced me to put under form tag then it forced me to specify action. If I specify an action which does not have a formBean then I am getting exception.If I give an action which have dummy formBean associated with it then I am getting exception like getter method not defined for that bean.Why it is expecting a formBean when I am just trying to populate it?.
Apreacite your reply's.
Thanks
sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
OK.I just did some changes to my code after reading couple of threds. I have created a form bean with getters and setters and commented this line in my code. //session.setAttribute("products", products);
I am still geting No getter method available exception.
//startForm:
public ArrayList getProducts() {
return products;
}
public void setProducts(ArrayList products) {
this.products = products;
}
//StartAction:

HttpSession session = request.getSession();
ProductProcessor pp = new ProductProcessor();
int debugLevel = servlet.getDebug();
ArrayList products = null;
StartForm startForm = (StartForm)form;

try{
ProductBean pb = pp.getAllProductsByProductGroup();
products = pb.getProductNames();
startForm.setProducts(products);
}catch(PersistenceException pe){
;
}
sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
//My JSP looks like this.
<html:form action="/LogonSubmit" >
<html:select property="products">
</html:select>
</html:form>
//struts-config.xml
<form-beans>
<form-bean name="startForm" type="app.StartForm"/>
</form-beans>
<action-mappings>

<action path="/Start" type="app.StartAction" name="startForm" scope="session">
<forward name="start" path="/pages/Start.jsp"/>
</action>
</action-mappings>
Martin Riedl
Greenhorn

Joined: Sep 06, 2003
Posts: 7
Hi,
your JSP calls an Action with the path "/LogonSubmit" - in your config-File your ActionPath says "/Start". I guess these two paths should match together, so try to change your JSP to "/Start" instead of "LogonSubmit".
sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
I resolved this problem.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Select Tag
 
Similar Threads
multiple submit buttons in jsp
HElp in Map-backed ActionForm
Repopulating form in struts2
how to populate a list in a another select tag using a select tag using struts 2 & DOJO (ajax)
Cannot find bean in any scope