Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Options Tag using Struts

 
Kevin Valencia
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you have a list of beans, it's better to use the htmlptionsCollection tag than htmlptions. Example:

You could do it using htmlptions, 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks Merill!!
Got it to work now! I've placed it in session scope though.
Really appreciate it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic