• 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

struts form submiision with hashmaps

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been trying to solve this problem for the last few weeks and getting no where, I'm hoping someone can help me.

I've got a list of records, with each field a text box, against each row there's an edit link which saves the details to the database.

I was using a Array of strings but was getting a nullpointerexception in beanutils.

I've got the code below to work using a dynaactionform but I've rather not use them and want to try and solve the issue.

The code below works and allows me to access the new values in my action class.

My problem is that when I add the following line within the iterator I get the exception listed below when you click on the edit link, the only difference on the line is the property

<html-el:text property="val(${refRecords.value.id})"
value="${refRecords.value.label}"/>

To me it seems to be a problem when your trying to submit values to 2 different HashMaps?

Does anyone have any ideas?

Here's an extract of my code....

--------------------
jsp page
<logic:iterate id="refRecords" name="adminReferenceDataForm"
property="refRecords" indexId="indexId">
<html:hidden name="refRecords" property="value.id" />

<html-el:text property="lab(${refRecords.value.id})"
value="${refRecords.value.label}"/>

<html-el:link href="#"
on click="document.adminReferenceDataForm.index.value=${pageScope.indexId};do
cument.adminReferenceDataForm.submit();return false;">
<img src="images/edit.gif" border="0" alt="Edit"/>
</html-el:link>

</logic:iterate

--------------------
form bean

private HashMap lab=new HashMap();
private HashMap refRecords=new HashMap(); // each element here contains a
bean with properties id, label, value etc.....


public void setRefRecords(HashMap refRecords)
{
this.refRecords = refRecords;
}


public HashMap getRefRecords()
{
return refRecords;
}

public void setLab(HashMap lab)
{
this.lab = lab;
}


public HashMap getLab()
{
return lab;
}


public void setLab(String x,Object lab)
{
this.lab.put(x,lab);
}


public Object getLab(String x)
{
return lab.get(x);
}

// same code as lab above for property val

--------------------





05/11/21 13:04:02 Project-ViewController-webapp: Servlet error
java.lang.IllegalArgumentException: No bean specified
at
org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(PropertyUti
ls.java:837)
at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:934)
at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:821)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(10.1.2.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.j
ava:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(10.1.2.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDisp
atcher.java:649)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(10.1.2.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRe
questDispatcher.java:322)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(10.1.2.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandl
er.java:790)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270
)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112
)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(10.1.2.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableR
esourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
 
Paul wilk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
solved problem by removing hidden field
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic