You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sr...@wachovia.com on 2007/10/18 19:47:22 UTC
(beginner) How to intialize a form's input item
Hi,
I am starter in Struts. I am using 1.3.8.
My requirement: Prepopulate a form feild if value is present.
Can anybody help me in intializing a input feild using struts custom tags?
Thanks
H.
RE: (beginner) How to intialize a form's input item
Posted by sr...@wachovia.com.
Silly one.. Thanks:)
Dave Newton <ne...@yahoo.com>
10/18/2007 03:01 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>
To
Struts Users Mailing List <us...@struts.apache.org>
cc
Subject
RE: (beginner) How to intialize a form's input item
You're creating a new ActionForm instead of using the
one provided to you.
--- sriharsha.chevuru@wachovia.com wrote:
> It doesn't seem to work. I am not getting the value
> which I am setting in
> TestAction.java in the ActionForm.jsp. Here is what
> i did, (its a test
> app), Please have a look at it and correct me:
>
> struts_config.xml
>
> <struts-config>
> <form-beans>
> <form-bean
> name="processForm"
> type="app.ProcessForm"/>
>
> </form-beans>
>
> <global-forwards>
> <forward
> name="welcome"
> path="/Welcome.do"/>
> </global-forwards>
>
> <action-mappings>
> <action
> path="/Welcome" type="app.TestAction"
> name="processForm"
> validate="false">
> <forward name="test"
> path="/pages/AcceptForm.jsp"
> />
> </action>
> <action
> path="/ProcessAction"
> type="app.ProcessAction"
> name="processForm"
> scope="session"
> validate="false"
> input="/pages/Input.jsp">
> <forward name="end"
> path="/pages/End.jsp"/>
> </action>
> <action
> path="/Page1Action"
> parameter="/pages/End.jsp"
>
> type="org.apache.struts.action.ForwardAction"/>
>
> </action-mappings>
> <message-resources parameter="MessageResources"
> />
>
> <plug-in
> className="org.apache.struts.tiles.TilesPlugin" >
> <set-property property="definitions-config"
>
> value="/WEB-INF/tiles-defs.xml" />
> <set-property property="moduleAware"
> value="true" />
> <set-property
> property="definitions-parser-validate" value="true"
> />
> </plug-in>
>
> <plug-in
>
className="org.apache.struts.validator.ValidatorPlugIn">
> <set-property
> property="pathnames"
>
>
value="/org/apache/struts/validator/validator-rules.xml,
> /WEB-INF/validation.xml"/>
> </plug-in>
> </struts-config>
>
> ProcessForm.java
>
> public class ProcessForm extends ActionForm {
> private String salutation;
> private String name;
> private String username;
> private String password;
> private String email;
> static final long serialVersionUID = 1;
>
> public String getEmail() {
> return email;
> }
> public void setEmail(String email) {
> this.email = email;
> }
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String password) {
> this.password = password;
> }
> public String getSalutation() {
> return salutation;
> }
> public void setSalutation(String salutation)
> {
> this.salutation = salutation;
> }
> public String getUsername() {
> return username;
> }
> public void setUsername(String username) {
> this.username = username;
> }
> }
>
> TestAction.java
>
> public class TestAction extends Action {
>
> public ActionForward execute(ActionMapping
> arg0, ActionForm arg1,
> HttpServletRequest arg2, HttpServletResponse arg3)
> throws Exception {
> ProcessForm processForm = new
> ProcessForm();
> processForm.setUsername("Its
> Successful");
> return arg0.findForward("test");
> }
> }
>
> AcceptForm.jsp
>
> <%@ taglib uri="struts-html" prefix="html" %>
>
> <html>
> <head>
> <title>Start Page</title>
> </head>
> <body>
> <h2>Trial Form</h2>
> <html:form action="/ProcessAction">
> User Name: <html:text
> property="username"/><br/>
> Password: <html:password
> property="password"/><br/>
> Email: <html:text property="email"/><br/>
> <html:submit value="Submit"/>
> </html:form>
> </body>
> </html>
>
> Thank you
> -H
>
>
>
> "Slattery, Tim - BLS" <Sl...@bls.gov>
> 10/18/2007 11:55 AM
>
> Please respond to
> "Struts Users Mailing List" <us...@struts.apache.org>
>
>
> To
> "Struts Users Mailing List" <us...@struts.apache.org>
> cc
>
> Subject
> RE: (beginner) How to intialize a form's input item
>
>
>
>
>
>
> > My requirement: Prepopulate a form feild if value
> is present.
>
> > Can anybody help me in intializing a input feild
> using struts
> > custom tags?
>
> The tags look for a corresponding property in the
> form bean, and take an
> initial value from that. For example, if this tag is
> in you JSP file:
>
> <html:text property="name"/>
>
> Struts will call the getter method "String
> getName()" in your form bean.
> Whatever that method returns will be the starting
> value in the text box.
>
> --
> Tim Slattery
> Slattery_T@bls.gov
>
>
>
=== message truncated ===
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
ForwardSourceID:NT0000D74A
RE: (beginner) How to intialize a form's input item
Posted by Dave Newton <ne...@yahoo.com>.
You're creating a new ActionForm instead of using the
one provided to you.
--- sriharsha.chevuru@wachovia.com wrote:
> It doesn't seem to work. I am not getting the value
> which I am setting in
> TestAction.java in the ActionForm.jsp. Here is what
> i did, (its a test
> app), Please have a look at it and correct me:
>
> struts_config.xml
>
> <struts-config>
> <form-beans>
> <form-bean
> name="processForm"
> type="app.ProcessForm"/>
>
> </form-beans>
>
> <global-forwards>
> <forward
> name="welcome"
> path="/Welcome.do"/>
> </global-forwards>
>
> <action-mappings>
> <action
> path="/Welcome" type="app.TestAction"
> name="processForm"
> validate="false">
> <forward name="test"
> path="/pages/AcceptForm.jsp"
> />
> </action>
> <action
> path="/ProcessAction"
> type="app.ProcessAction"
> name="processForm"
> scope="session"
> validate="false"
> input="/pages/Input.jsp">
> <forward name="end"
> path="/pages/End.jsp"/>
> </action>
> <action
> path="/Page1Action"
> parameter="/pages/End.jsp"
>
> type="org.apache.struts.action.ForwardAction"/>
>
> </action-mappings>
> <message-resources parameter="MessageResources"
> />
>
> <plug-in
> className="org.apache.struts.tiles.TilesPlugin" >
> <set-property property="definitions-config"
>
> value="/WEB-INF/tiles-defs.xml" />
> <set-property property="moduleAware"
> value="true" />
> <set-property
> property="definitions-parser-validate" value="true"
> />
> </plug-in>
>
> <plug-in
>
className="org.apache.struts.validator.ValidatorPlugIn">
> <set-property
> property="pathnames"
>
>
value="/org/apache/struts/validator/validator-rules.xml,
> /WEB-INF/validation.xml"/>
> </plug-in>
> </struts-config>
>
> ProcessForm.java
>
> public class ProcessForm extends ActionForm {
> private String salutation;
> private String name;
> private String username;
> private String password;
> private String email;
> static final long serialVersionUID = 1;
>
> public String getEmail() {
> return email;
> }
> public void setEmail(String email) {
> this.email = email;
> }
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String password) {
> this.password = password;
> }
> public String getSalutation() {
> return salutation;
> }
> public void setSalutation(String salutation)
> {
> this.salutation = salutation;
> }
> public String getUsername() {
> return username;
> }
> public void setUsername(String username) {
> this.username = username;
> }
> }
>
> TestAction.java
>
> public class TestAction extends Action {
>
> public ActionForward execute(ActionMapping
> arg0, ActionForm arg1,
> HttpServletRequest arg2, HttpServletResponse arg3)
> throws Exception {
> ProcessForm processForm = new
> ProcessForm();
> processForm.setUsername("Its
> Successful");
> return arg0.findForward("test");
> }
> }
>
> AcceptForm.jsp
>
> <%@ taglib uri="struts-html" prefix="html" %>
>
> <html>
> <head>
> <title>Start Page</title>
> </head>
> <body>
> <h2>Trial Form</h2>
> <html:form action="/ProcessAction">
> User Name: <html:text
> property="username"/><br/>
> Password: <html:password
> property="password"/><br/>
> Email: <html:text property="email"/><br/>
> <html:submit value="Submit"/>
> </html:form>
> </body>
> </html>
>
> Thank you
> -H
>
>
>
> "Slattery, Tim - BLS" <Sl...@bls.gov>
> 10/18/2007 11:55 AM
>
> Please respond to
> "Struts Users Mailing List" <us...@struts.apache.org>
>
>
> To
> "Struts Users Mailing List" <us...@struts.apache.org>
> cc
>
> Subject
> RE: (beginner) How to intialize a form's input item
>
>
>
>
>
>
> > My requirement: Prepopulate a form feild if value
> is present.
>
> > Can anybody help me in intializing a input feild
> using struts
> > custom tags?
>
> The tags look for a corresponding property in the
> form bean, and take an
> initial value from that. For example, if this tag is
> in you JSP file:
>
> <html:text property="name"/>
>
> Struts will call the getter method "String
> getName()" in your form bean.
> Whatever that method returns will be the starting
> value in the text box.
>
> --
> Tim Slattery
> Slattery_T@bls.gov
>
>
>
=== message truncated ===
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: (beginner) How to intialize a form's input item
Posted by sr...@wachovia.com.
It doesn't seem to work. I am not getting the value which I am setting in
TestAction.java in the ActionForm.jsp. Here is what i did, (its a test
app), Please have a look at it and correct me:
struts_config.xml
<struts-config>
<form-beans>
<form-bean
name="processForm"
type="app.ProcessForm"/>
</form-beans>
<global-forwards>
<forward
name="welcome"
path="/Welcome.do"/>
</global-forwards>
<action-mappings>
<action
path="/Welcome" type="app.TestAction"
name="processForm"
validate="false">
<forward name="test" path="/pages/AcceptForm.jsp"
/>
</action>
<action
path="/ProcessAction"
type="app.ProcessAction"
name="processForm"
scope="session"
validate="false"
input="/pages/Input.jsp">
<forward name="end" path="/pages/End.jsp"/>
</action>
<action
path="/Page1Action"
parameter="/pages/End.jsp"
type="org.apache.struts.action.ForwardAction"/>
</action-mappings>
<message-resources parameter="MessageResources" />
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/org/apache/struts/validator/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
ProcessForm.java
public class ProcessForm extends ActionForm {
private String salutation;
private String name;
private String username;
private String password;
private String email;
static final long serialVersionUID = 1;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSalutation() {
return salutation;
}
public void setSalutation(String salutation) {
this.salutation = salutation;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
TestAction.java
public class TestAction extends Action {
public ActionForward execute(ActionMapping arg0, ActionForm arg1,
HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
ProcessForm processForm = new ProcessForm();
processForm.setUsername("Its Successful");
return arg0.findForward("test");
}
}
AcceptForm.jsp
<%@ taglib uri="struts-html" prefix="html" %>
<html>
<head>
<title>Start Page</title>
</head>
<body>
<h2>Trial Form</h2>
<html:form action="/ProcessAction">
User Name: <html:text property="username"/><br/>
Password: <html:password property="password"/><br/>
Email: <html:text property="email"/><br/>
<html:submit value="Submit"/>
</html:form>
</body>
</html>
Thank you
-H
"Slattery, Tim - BLS" <Sl...@bls.gov>
10/18/2007 11:55 AM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>
To
"Struts Users Mailing List" <us...@struts.apache.org>
cc
Subject
RE: (beginner) How to intialize a form's input item
> My requirement: Prepopulate a form feild if value is present.
> Can anybody help me in intializing a input feild using struts
> custom tags?
The tags look for a corresponding property in the form bean, and take an
initial value from that. For example, if this tag is in you JSP file:
<html:text property="name"/>
Struts will call the getter method "String getName()" in your form bean.
Whatever that method returns will be the starting value in the text box.
--
Tim Slattery
Slattery_T@bls.gov
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
ForwardSourceID:NT0000D736
RE: (beginner) How to intialize a form's input item
Posted by "Slattery, Tim - BLS" <Sl...@bls.gov>.
> My requirement: Prepopulate a form feild if value is present.
> Can anybody help me in intializing a input feild using struts
> custom tags?
The tags look for a corresponding property in the form bean, and take an
initial value from that. For example, if this tag is in you JSP file:
<html:text property="name"/>
Struts will call the getter method "String getName()" in your form bean.
Whatever that method returns will be the starting value in the text box.
--
Tim Slattery
Slattery_T@bls.gov
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org