I have a working Action and JSP form that I use to create new objects in my most basic Struts 2.2.1.1 application. I am trying to modify an application to reuse the same JSP form for editing objects.
I have added a "hidden" identifier tag and now I get errors when I submit the form. Can someone please help me?
I looked for this problem and saw others posting similar errors, but I'm not sure how to resolve it.
Excerpt from Stack Trace when submitting a form:
2011-05-02 11:09:36,132 3198497 ["http-bio-8080"-exec-23] WARN com.opensymphony.xwork2.ognl.OgnlValueStack - Error setting expression 'id' with value '[Ljava.lang.String;@100ac03' ognl.MethodFailedException: Method "setId" failed for object org.robbins.flashcards.model.Tag@1b9eb34 [name='null' ] [java.lang.NoSuchMethodException: org.robbins.flashcards.model.Tag.setId([Ljava.lang.String;)] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1285) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
Excerpt from JSP:
<%@ taglib prefix="s" uri="/struts-tags"%> ... <s:form action="saveOrUpdateTag" method="post"> <s:hidden name="id" /> <s:textfield name="name" key="label.tag.name" size="20" /> <s:submit label="label.flashcard.submit" align="center" /> </s:form>
Excerpt from action class:
public class TagAction extends FlashCardsAppBaseAction implements ModelDriven<Tag> { Tag tag = new Tag(); public Tag getTag() { return tag; } public void setTag(Tag tag) { this.tag = tag; } public String createTag() { ... } }
Excerpt from POJO:
public class Tag implements java.io.Serializable { private int id; private String name; public int getId() { return this.id; } public void setId(int id) { this.id = id; } ... }
Excerpt from Struts.xml
<action name="saveOrUpdateTag" class="org.robbins.flashcards.presentation.TagAction" method="createTag"> <result name="success" type="tiles">displaytag.tiles</result> <result name="input" type="tiles">tagform.tiles</result> </action>
FYI. I also submitted this question to the Struts-User mailing list, but received no input, so I will post it here as well. I will update another post and vice versa when more information appears.
source share