• 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

html:optionsCollection - Help Needed!

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I have been working on this prbm for the past 2 day2... I am totally lost. I know there were some posts regd the same prbm. I went thro' them but fail to find out where I am making the mistake.

PLEASE HELP ... Thanks a ton in advance...


The Error:
~~~~~~~~~~
9:06:40,633 ERROR [[action]] Servlet.service() for servlet action threw exception
javax.servlet.jsp.JspException: Failed to obtain specified collection
at org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:181)


ActionForm Contains (LeadFlowAnalysisReportForm):
~~~~~~~~~~~~~~~~~~~~

private Collection companies;
private String compId;
private String compName;

public Collection getCompanies() {
return companies;
}
public void setCompanies(Collection companies) {
this.companies = companies;
}
public String getCompId() {
return compId;
}

public void setCompId(String compId) {
this.compId = compId;
}
public String getCompName() {
return compName;
}
public void setCompName(String compName) {
this.compName = compName;
}


Action Class contains (This returns values correctly from DAO):
~~~~~~~~~~~~~~~~~~~~~~

LeadFlowAnalysisReportForm leadFlowAnalysisRptFrm = (LeadFlowAnalysisReportForm)actionForm;
WebDelegate webDelegate = serviceLocator.getWebDelegate();
List companies = webDelegate.findAllCompanies();
log.debug("Got the company values from Hibernate. Setting it to Form");
leadFlowAnalysisRptFrm.setCompanies(companies);



JSP Contains:
~~~~~~~~~~~~~
<td><html:select property="companySearchId" style="width:165px;">
<html ptionsCollection property="companies" label="compId" value="compName" />
</html:select></td>



VO Contains:
~~~~~~~~~~~~

public class CompanyGeneralConfigVO
{
String compId;
String compName;



public String getCompId() {
return compId;
}
public void setCompId(String compId) {
this.compId = compId;
}
public String getCompName() {
return compName;
}
public void setCompName(String compName) {
this.compName = compName;
}

}
 
VJ Subra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody ??!!! PLS HELP
 
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 mistake people commonly make is getting the horse before the cart. The action class that you've shown us populates the Collection of companies, but are you sure you're calling this action before the JSP is displayed and not after?

Make sure this action forwards to the JSP, and then call the URL for the action (myserver/myapplication/myaction.do) rather than calling the JSP directly (myserver.myapplication/mypage.jsp).
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Merrill... you got it right!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic