wood burning stoves 2.0*
The moose likes Struts and the fly likes struts form submiision with hashmaps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts form submiision with hashmaps" Watch "struts form submiision with hashmaps" New topic
Author

struts form submiision with hashmaps

Paul wilk
Greenhorn

Joined: Nov 21, 2005
Posts: 3
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

Joined: Nov 21, 2005
Posts: 3
solved problem by removing hidden field
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts form submiision with hashmaps