• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem with Options Tag using Struts

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello...
I have 2 pages, main.jsp and add.jsp, when a button from the main.jsp is clicked, it will add.jsp and should populate a select box in this page.
I'm encountering this error when trying to populate the select box with data coming from the database: javax.servlet.jsp.JspException: No getter method available for property strTemplateDesc for bean under name matrixList org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:210)

Please help, i've just started experimenting with struts.
Appreciate it!

Below is my source code:

---JSP (add.jsp)
---FORM BEAN (form bean of main.jsp)

---ACTION CLASS (action class of main.jsp)
---DAO



[BSouther: Added UBB CODE tags]
[ September 05, 2007: Message edited by: Ben Souther ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kevin,
Welcome to JavaRanch.
I'm going to move this to our Struts forum where it stands a better chance of getting a good answer.

-Ben
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Kevin.

From your code it looks like "matrixList" is a collection of label value benas. You should try something like:

 
Kevin Valencia
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leandro,
Thanks for the reply. I tried what you've suggested and a different error was displayed: javax.servlet.ServletException: Cannot find bean under name matrixList

i cant see why this is so, because i've already placed matrixList in my form bean.

would appreciate if you can shed some light on this.

Thanks!
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you have a list of beans, it's better to use the html:optionsCollection tag than html:options. Example:

You could do it using html:options, but you'd have to use a bean:define tag along with it. Example:

[ September 05, 2007: Message edited by: Merrill Higginson ]
 
Kevin Valencia
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,
Thanks for the reply, i did what you've suggested and i encountered this error: javax.servlet.ServletException: Failed to obtain specified collection.
Is there anything lacking in my bean? i already placed a getter/setter for the select tag property but that didnt solve it. i checked the result from the dao and it was successfully retrieved.
Really appreciate your help!
Thanks!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One problem I see is that in your Action class, you create an instance of StripAddForm and set its properties, but you don't put this instance into any scope. You must place this instance into the scope specified by the action mapping (either request or session) and use the same name used by the action mapping's name attribute. So, if the scope is request, and the name is stripAddForm, you must add the following statement to your Action class:

[ September 06, 2007: Message edited by: Merrill Higginson ]
 
Kevin Valencia
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill!!
Got it to work now! I've placed it in session scope though.
Really appreciate it.
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic