• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

My html:select is not working

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to use html:select in my application for drop down box. but i get an exception

here is my code:
<html:select property="snvendor" name="batchbillForm">
<html ption value="DTDC Courier"/>
<html ption value="JetAirways"/>
<html ption value="CitiTaxi"/>
</html:select>

My ActionForm

private String snvendor=null;
public void setSnVendor(String snvendor)
{
this.snvendor=snvendor;
}
public String getSnVendor()
{
return snvendor;
}

When i run my application it gives the following exception...
No getter method available for property snvendor for bean under name batchbillForm
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.BatchBill_jsp._jspService(BatchBill_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
surendar prabu
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also help me how I can achieve this using <logic:iterate> tag without hard coding values for <html ption> tag.

I think i may have to use the bean:write tag.
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Surendar,
Hi! I dont know why you have not searched the forum for the same. ALready a thread gives the answer to the same.
https://coderanch.com/t/54560/Struts/help-please...


Regards,
Roshani
 
surendar prabu
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roshani,
but again i am getting the exception...

Now my code is this....
<html:select style="WIDTH: 175px" property="snvendor">
<html ptions name="vendor" />
</html:select>

My Actionform now has a collection
private Collection vendor=null;

public void setVendor(Collection vendor)
{
this.vendor=vendor;
}
public Collection getVendor()
{
return vendor;
}

This collection is loaded by an ArrayList in my Action.
My Exception is this.....

javax.servlet.ServletException: No getter method available for property snvendor for bean under name org.apache.struts.taglib.html.BEAN
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.BatchBill_jsp._jspService(BatchBill_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Please help me..

Specify the error in my code if there is any....
regards,
surendar
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the property name in your <html:select> tag is snvendor, the getter method name in your ActionForm must be getSnvendor(), not getSnVendor().
 
surendar prabu
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I got rid of that exception. But i have some other problem.

<html:select style="WIDTH: 175px" property="snvendor">
<html ptions name="batchbillForm" property="vendor"/>
</html:select>

My code in Action to load the collection

ResultSet rs=dbm.get_ResultSet("bbill");
rs.first();
while(rs.next())
{
vendor.add(new Vendor(rs.getString(1)));
}
rs.close();

bbf.setVendor(vendor);

I have a class Vendor. the code is

public class Vendor {
private String vendor;

/** Creates a new instance of Selections */
public Vendor() {
}
public Vendor(String vendor)
{
this.vendor=vendor;
}
public void setVendor(String vendor)
{
this.vendor=vendor;
}
public String getVendor()
{
return vendor;
}

When i run this application instead of loading the dropdown box with Strings, the <html ptions> tag load my dropdown box with Objects like this btch.Vendor@13497. Which is the best tag to get my Sring values.

For my ordinary text boxes i am using logic:iterate tag and it is working fine.

Please help me.
Some one advised me to use ordinary select tag and between the options tag load the values using bean:write. can i follow that?

regards
Surendar.
 
surendar prabu
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill

In a thread regarding this you have given this code..

<html:select property="location" styleClass="textfield"> <html ptions name="locationList" /></html:select>

But that is not working for me. the exception says some thing like

Cannot find bean with name vendor.

So i have tried with the code that is given in my previous post. that displays the JSP page but with the dropdown loaded with objects.
 
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
If your collection contains objects rather than Strings, it is generally better to use the <html:optionsCollection> tag rather than the <html:options> tag. Example:

<html:optionsCollection name="batchbillForm" property="vendor" value="vendor" label="vendor" />

Here is the link to the documentation for this tag.
[ September 06, 2006: Message edited by: Merrill Higginson ]
 
surendar prabu
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thaks Merrill .Thats Great working fine.


regards,
Surendar
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic