You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Subhani Shaik <ss...@gmail.com> on 2007/08/30 15:04:45 UTC

Problem in Parameter passing.

Hi,

I have a problem while passing some data from my JSP to Action action class.

I have a JSP in which I have a text field. Whwn I submit the page, I need to
get the text entered in the JSP into Action. I read in a article that if i
implement ParameterAware interface to my action class and override the
setParameter() and getParameter() methods, i would get the JSP data into
parameters (Map). I tried this and my parameter map is becoming empty.
I have mapped interceptor in my struts.xml action mapping.

Could you plese help me out in resolving this?

-- 
View this message in context: http://www.nabble.com/Problem-in-Parameter-passing.-tf4354138.html#a12406757
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem in Parameter passing.

Posted by Subhani Shaik <ss...@gmail.com>.
Hi,

I understand the problem. I am using the <s:url action="xyz">Click here
</s:url> for making the action and I dont have <form> defined in my JSP. If
we use like this, we may not receive the parameters in the current form to
be transfered to our Action class by using ParameterAware features. Hence,
keep the fields with in <form > tags and the submit action. You will get the
data.
-- 
View this message in context: http://www.nabble.com/Problem-in-Parameter-passing.-tf4354138.html#a12421083
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem in Parameter passing.

Posted by ch...@highmark.com.
Shaik,

Assuming you are using Struts1, you need to define your data in a struts 
ActionForm class.  Make sure that the name of your variable is the same in 
the ActionForm as in the jsp control, and then you will be able to access 
it using the form object from within the execute method of your struts 
Action class.  Make sure that you have defined a setter and getter for the 
variable in your Action Form.  Then you will be able to easily reference 
the same data in the jsp, the Form class, and the Action.
For example...
<html:text property="variable1"/> 
<%-- The name attribute above is not needed as it is assumed to be the 
ActionForm if not specified -->

public class YourForm extends ActionForm {
...
        private String variable1;
        ...
        public String getVariable1() {
                return variable1;
        }
        public void setVariable1(String variable1) {
                this.variable1 = variable1;
        }...
}
public class YourAction extends Action {
public ActionForward execute (
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
        throws Exception {
        ...
        YourForm yourForm = (YourForm) form;
        ...
        String yourString = yourForm.getVariable1();
        ... 
}
Regards,
Chris Stewart



"Subhani Shaik" <ss...@gmail.com> 
08/30/2007 09:04 AM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
user@struts.apache.org
cc

Subject
Problem in Parameter passing.







Hi,

I have a problem while passing some data from my JSP to Action action 
class.

I have a JSP in which I have a text field. Whwn I submit the page, I need 
to
get the text entered in the JSP into Action. I read in a article that if i
implement ParameterAware interface to my action class and override the
setParameter() and getParameter() methods, i would get the JSP data into
parameters (Map). I tried this and my parameter map is becoming empty.
I have mapped interceptor in my struts.xml action mapping.

Could you plese help me out in resolving this?

-- 
View this message in context: 
http://www.nabble.com/Problem-in-Parameter-passing.-tf4354138.html#a12406757

Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org