Hi,

When you call an action from href, it doesn't submit the form. In order to
do so, write a small JavaScript, which will submit the form on click of the
link. Struts will initialize the form only if doGet/doPost is called and
then pass it to the action class.

HTH,


On 5/20/06, red phoenix <[EMAIL PROTECTED]> wrote:

I have two jsp file,such a.jsp and b.jsp,one Action file and one Form
file,I
want to from a.jsp to call Action file,and I set value of Form in Action
file,and return to b.jsp,and show value in b.jsp,so I can modify this
value
in b.jsp
my struts-config.xml is follows:
<form-beans>
   <form-bean
     name="TestForm"
     type="Test.TestForm"/>
</form-beans>
<action-mappings>
<action path="/test"
type="Test.TestAction"
   name="TestForm"
   scope="request"
   input="/b.jsp">
   <forward name="cc" path="/b.jsp" />
</action>
</action-mappings>

/*b.jsp*/
...
<html:form method="post" action="nextTest.do">
<html:text property="name"/>
<html:text property="card"/>
</html:form>
/*TestForm.java*/
Package Test
...
public class TestForm extends ActionForm{
private String name;
private String card;
public String getName(){
  return name;
}
public String getCard(){
  return card;
}
public void setName(String name){
  this.name=name;
}
public void setCard(String card){
  this.card=card;
}
}

/*TestAction.java*/
Package Test;
...
public class TestAction extends Action{
TestForm f=(TestForm)form;
//here query some data from database
//and put the query result in TestForm
//so it will show them in b.jsp and I can change the value in b.jsp
f.setName("John");
f.setCard("10000");
return mapping.findForward("cc");
}

First I show a.jsp page,and there is a href in this page,when click this
href and it will point to /test,but it raise error,it say Null exception
at
f.setName("John") in TestAction.java,I guess TestForm may be  null.How to
do to realize put some value in Form through Action and put return to
b.jspshow and may modify these value in
b.jsp?

Thanks in advance




--
Vinit Sharma
IBM

Reply via email to