aspose file tools*
The moose likes Struts and the fly likes html:optionsCollection - Help Needed! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:optionsCollection - Help Needed!" Watch "html:optionsCollection - Help Needed!" New topic
Author

html:optionsCollection - Help Needed!

VJ Subra
Greenhorn

Joined: Jan 23, 2008
Posts: 3
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

Joined: Jan 23, 2008
Posts: 3
Anybody ??!!! PLS HELP
Merrill Higginson
Ranch Hand

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


Merrill
Consultant, Sima Solutions
Guy Belpa
Ranch Hand

Joined: Nov 21, 2004
Posts: 41
thanks Merrill... you got it right!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:optionsCollection - Help Needed!