Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:optionsCollection - Help Needed!

 
VJ Subra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Anybody ??!!! PLS HELP
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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).
 
Guy Belpa
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Merrill... you got it right!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic