Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Struts:FormBean issue with html:select tag

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP that has the following code:
<html:select name="formBean" property="textId">
<html: options
collection="WORDS"
property="txtBody"
labelProperty="txtName"
<html: options
</html:select>
I have the setters and getters for the bean attributes in the form bean that is defined in the struts-config.xml file as:
<form-beans>
<form-bean name="formBean" type="com.xora.apps.messaging.presentation.form.MyForm
</form-beans>
The collection WORDS is set in the request attribute and contains a List of values when the action form is called(ie when the form loads) to be populated in the options tag. But when the form loads the message:
500 Servlet Exception
javax.servlet.jsp.JspException: Cannot find bean under name formBean
is displayed even after manually creating the formBean instance in the ActionForm page as
MyForm formBean = new MyForm();
Any fix suggested would be greatly appreciated...
-Ali
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, I'm assuming that the form-bean tag is not left open like that in your struts-config. And the same with your html:options tags.
It's usually best practice to use the ActionForm associated with the jsp for retrieving values if they are to come from an ActionForm at all.
Simply creating the other form (which I assume to be another ActionForm) inside the ActionForm associated with your jsp does not do anything beneficial on its own. You also need to create a getter for it. Your app is looking for a getFormBean() method in the ActionForm.
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic