• 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

problem to get values in hasmap in bean:write

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am setting hash map in action class
parsingForm.setMap(map);
--------------------------------------
formbean is having fallowing methods
--------------------------------------
/**
* @return
*/
public HashMap getMap() {

return map;
}

/**
* @param map
*/
public void setMap(HashMap map) {
this.map = map;
}

/**
* @return
*/

public Object getStringMapped(String key) {
System.out.println("inside parseingFormbean "+ map.get("name"));
return map.get(key);
}

/**
* @param map
*/
public void setStringMapped(String key, Object value) {
map.put(key, value);
}


------------------------------------
jsp
--------------------------------------
<jsp:useBean id="bean" class="forms.parsingForm"/>
<bean:write name="bean" property="stringMapped(name)"/>
the out put is not showing any value
the debug statment in formbean is giving null value
can any one guide me in this regard ?
thanks in advance
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

is ur instance varible in the form-bean is assigned to a new HashMap like

private HashMap map = new HashMap();

else evrything is fine and should work

and dont use <jsp:useBean> directly use bean:write to look up the value
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply
yes i created new instance of hash map in the form bean how can i avoid that one .
thanks for the reply.
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i chnaged the
HashMap map = new HashMap();
to HashMap map ;
in the form bean
how to avoid look up
<jsp:useBean id="propertyval" class="forms.parsingForm"
scope="request"/>
with bean:write as bean write does not take class as parameter
thanks for the reply
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
o have used fallowing code its throwing error bean user not found

[Servlet Error]-[Cannot find bean forms.parsingForm in any scope]: javax.servlet.jsp.JspException: Cannot find bean forms.parsingForm in any scope


<logic:iterate id="user" name="forms.parsingForm" property="map">
<tr>
<td>User Id: <bean:write name=" user" property="key"/></td>
<td>Password: <bean:write name=" user" property="value"/></td>
</tr>
</logic:iterate>
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my struts config is
<action name="parsingForm" path="/parsing" type="actions.parsingAction" scope="request">
<forward name="success" path="/projselect.jsp">
</forward>
</action>


<form-bean name="parsingForm" type="forms.parsingForm">
</form-bean>


advice
thanks in advance
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
changed iterate to now giving error unable to iterate
<logic:iterate id="user" name="parsingForm" type="forms.parsingForm">
<tr>
<td>User Id: <bean:write name=" user" property="key"/></td>
<td>Password: <bean:write name=" user" property="value"/></td>
</tr>
</logic:iterate>
Cannot create iterator for this collection error
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i changed as fallows its working now
<logic:iterate id="user" name="parsingForm" property="map" >
 
reply
    Bookmark Topic Watch Topic
  • New Topic