×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Cannot propagate data from struts form to an Action Class

Cannot propagate data from struts form to an Action Class

Cannot propagate data from struts form to an Action Class

(OP)
I have a jsp page, Action and ActionForm classes.
When sending parameters from JSP to Action, parameters are not being propagated to Action class.

Here is what I have:

struts-config file:

<form-beans>
<form-bean name="myForm" type="path_to_form.FormClass">
</form-bean>
</form-beans>

<action-mappings>
<action path="/myAction" type="somePath.myAction" name="myForm" scope="request" input="/My.jsp">
</action>
</action-mappings>


JSP file:

function doSearch(val)
{
    //frm = document.forms['wbasPropsForm'];
    frm = document.wbasPropsForm;
    frm.operation.value = "search";
    
    if (checkForm(val))
    {
        frm.submit();
    }
}

<html:form action="myAction.do">
html:text property="strValue" styleClass="searchField"/>
</html:form>

ActionForm class:

public class FormClass extends ActionForm {
private String _strValue;

public String getStrValue(){return _strAvalue;}
public void setStrValue(String string){_strValue=string;}

Action class:

FormClass aFormClass = (FormClass) form;
session.setAttribute("myForm", aFormClass);

String val = Utils.trim(aFormClass.getStrValue());

............

val is not getting a value.

If anyone knows the answer to that, it would be greate.

RE: Cannot propagate data from struts form to an Action Class

Hi

Please :
  • copy & paste your code instead of typing
  • post your code between [code] and [/code] tags
  • specify some proper file names not just their type
By the way, are you sure that val should have a value ?

Feherke.
http://rootshell.be/~feherke/

RE: Cannot propagate data from struts form to an Action Class

(OP)
Yes, absolutelly.
That's an idea, so that value defines the feature logic flow.

Thank you for your reply.

Eugene

RE: Cannot propagate data from struts form to an Action Class

Hi

Because you posted a JavaScript function. Which in normal case case would have nothing to do in all this. And now I am wondering what is the reason you posted it. If that should be the one which populates the form field, then are you sure there has to be "operation" ?

CODE

 frm.operation.value = "search";
Searching for a logic flow, I have a feeling there should be "strValue".

Then there is that "A" in the getter :

CODE

public String getStrValue(){return _strAvalue;}
Again searching for a logic flow, I would expect to have "_strValue" there...

Feherke.
http://rootshell.be/~feherke/

RE: Cannot propagate data from struts form to an Action Class

(OP)
I just misspelled the variable.
In fact that is an _strValue.
The reason for me to have a javascript function on click event of the button is, that I have multiple buttons on my form that submit different parameters to the form.

The code that I sent it is just a fragment of the whole picture.

The entire code has one form with three buttons that are doing different actions for the form.
Each action is specified by the operation value.
"operation" is a hidden field on a form.

So, depending on that value, program will have different workflow.

By the way, when I retrieve operation in my Action class, it's value is being successfully retrieved.

Getter and Setter methods for "operation" attribute I specify in a parent class of my FormClass.
And then my FormClass extends that Parent class.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close