| Author |
Struggling with this - pls HELP!...
|
sue jacob
Greenhorn
Joined: Oct 06, 2005
Posts: 9
|
|
My JSP: <bean efine id="searchResults" name="GeneralMatterSearchForm" property="searchResults" scope="request" /> <logic:iterate id="currentResult" name="searchResults"> <tr class='off'> <td nowrap> <a href="javascript penLink('<bean:write name="currentResult" property="matterId"/>','_blank');" > <bean:write name="currentResult" property="matterId"/> </a> </td></tr> My FormBean: public class GeneralMatterSearchForm extends LegalAffairsBaseForm { private String matterName; private String keyWords; private String matterId; private List searchResults = new ArrayList(0); public List getSearchResults() { return searchResults; } public void setSearchResults(List searchResults) { this.searchResults = searchResults; } I am getting the searchResults here: public class GeneralMatterSearchDAO extends AbstractDAO { public GeneralMatterSearchDAO() { } //the getSearchResults method returns me the searchResults in a list. public List getSearchResults(MatterSearchBean oSearchBean, GeneralMatterSearchForm actionForm) throws LawPackException { //I have all the logic for connecting to the datbase and returning me the search results here// return searchResults; In my Action Form I have: List l_results = genMatterSearchDAO.getSearchResults(oSearchBean,l_pageForm); l_pageForm.setSearchResults(l_results); } <td nowrap><bean:write name="currentResult" property="matterName"/></td>
|
 |
sue jacob
Greenhorn
Joined: Oct 06, 2005
Posts: 9
|
|
it got submitted before i could finish my questin by mistake!... i am getting "No getter method for property matterId of bean currentResult at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968) what is my mistake....
|
 |
alan do
Ranch Hand
Joined: Apr 14, 2005
Posts: 354
|
|
|
check your jguru posting.
|
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
|
 |
sue jacob
Greenhorn
Joined: Oct 06, 2005
Posts: 9
|
|
Alan, Thanks much for your response... i have changed the code to implement the way u had suggested...so, now it looks like this.. my GeneralMatterSearchDAO public List getSearchResults(MatterSearchBean oSearchBean) throws LawPackException { -------- all database connection and other stmts to retrieve the data... return searchResults; } In my actionform GeneralMatterSearchAction, I have: GeneralMatterSearchDAO genMatterSearchDAO = new GeneralMatterSearchDAO(); MatterSearchBean oSearchBean = new MatterSearchBean(); List l_results = genMatterSearchDAO.getSearchResults(oSearchBean); AND THEN, I AM STUCK HERE!....NEED YOUR HELP!... SHOULD I HAVE SOMETHING LIKE THIS?... for (Iterator l_i = l_results.iterator(); l_i.hasNext() { List searchResultList=l_results??? } request.setAttribute("searchResults",searchResultList); Again, appreciate your efforts in helping me!.. Sue
|
 |
alan do
Ranch Hand
Joined: Apr 14, 2005
Posts: 354
|
|
you're on the right track... let's make it simple and see if we can use the list that comes back from the DAO. skip the iteration inside the Action class and just place the List in the request using request.setAttribute("searchResults",l_results); follow step 4 and 5 in my last suggestion. again, remember that the 'type' attribute of logic:iterate must be set to the correct class, that is whatever that is in each iteration of the l_results returned by the DAO. that class should contain the fields and getters and setters. the field names of this class are the ones you want to use INSIDE logic:iterate (using the bean:write tag).
|
 |
sue jacob
Greenhorn
Joined: Oct 06, 2005
Posts: 9
|
|
Alan, I think I am going somewhere wrong - not sure where!... ok - this is what i have as suggested by you!... In my action class, i have... request.setAttribute("searchResults",l_results); and in my jsp i included... <jsp:useBean id="searchResults" type="java.util.List" scope="request"/> <logic:iterate id="currentResult" name="searchResults" type="java.lang.String"> <tr class='off'> <td nowrap> <a href="javascript penLink('<bean:write name="currentResult" property="matterId"/>','_blank');" > <bean:write name="currentResult" property="matterId"/> </a> </td> <td nowrap><bean:write name="currentResult" property="matterName"/></td> AND OTHER BEAN WRITE FOR OTHER ATTRIBUTES.... my SearchResults class: public class SearchResults extends LegalValueBean{ protected String matterId = null; protected String matterName = null; protected String statusList = null; protected String practiceAreaList = null; protected String personInChargeList = null; protected String countryList=null; protected String businessUnitList = null; protected String relatedMatter = null; protected String keyWords = null; protected String statusCode; protected String practiceAreaCode; protected String personInChargeCode; protected String countryCode; protected String businessUnitCode; protected String relatedMatterCode; //private Collection m_searchResults = new ArrayList(0); //private List searchResults = new ArrayList(0); /** * Constructor for SearchResults. */ public SearchResults() { } public String getMatterId() { return matterId; } public void setMatterId(String matterId) { this.matterId = matterId; } AND OTHER GETTERS AND SETTERS.... sO, NOW FINALLY WHEN I EXECUTE, IT IS AGAIN GIVING ME THE SAME ERROR... No getter method for property matterId of bean currentResult
|
 |
alan do
Ranch Hand
Joined: Apr 14, 2005
Posts: 354
|
|
please tell me what List l_results = genMatterSearchDAO.getSearchResults(oSearchBean); returns. it's a List, but of what? what ever that object is, that should be the 'type' attribute of your logic:iterate. currently you have it as 'java.lang.String', which is incorrect. if it's a List of SearchResults, then the codes must be <logic:iterate id="currentResult" name="searchResults" type="com.my.app.SearchResults">
|
 |
sue jacob
Greenhorn
Joined: Oct 06, 2005
Posts: 9
|
|
Ok - this is what i am having now!... <jsp:useBean id="searchResults" type="java.util.List" scope="request"/> <logic:iterate id="currentResult" name="searchResults" type="com.mmm.legalcenter.lawpack.bean.SearchResults"> but now it gives me Class cast exception!... to answer your question, the l_results returns SearchResults thanks for guiding me all this way!
|
 |
 |
|
|
subject: Struggling with this - pls HELP!...
|
|
|