my dog learned polymorphism*
The moose likes Struts and the fly likes Problem with Options Tag using Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with Options Tag using Struts" Watch "Problem with Options Tag using Struts" New topic
Author

Problem with Options Tag using Struts

Kevin Valencia
Greenhorn

Joined: Aug 20, 2007
Posts: 18
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

Joined: Dec 11, 2004
Posts: 13410

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


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Hello Kevin.

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



Leandro Melo
SCJP 1.4, SCWCD 1.4
Kevin Valencia
Greenhorn

Joined: Aug 20, 2007
Posts: 18
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

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
Kevin Valencia
Greenhorn

Joined: Aug 20, 2007
Posts: 18
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

Joined: Feb 15, 2005
Posts: 4864
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

Joined: Aug 20, 2007
Posts: 18
Thanks Merill!!
Got it to work now! I've placed it in session scope though.
Really appreciate it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Options Tag using Struts
 
Similar Threads
update html:options
problem---how to display ArrayList of ArrayList in jsp page.
html:select html:options error, no getter. please help
html:optionsCollection - Help Needed!
Error in populating a Option List from Collection