| Author |
pass value from javascript to strutsaction class
|
naresh kumar k
Ranch Hand
Joined: May 25, 2011
Posts: 30
|
|
hi every one ,
I am new to javascript. In my project i am trying to call struts action method from javascript every thing goes fine but i am unable to get values from corresponding form class.
here is my jsp page:
in my action class :
Actually i am trying to set remaining fields in the page on loose focus of productName field.
Here exactly what i need is" productsForm.getProductName()" should return the data entered in jsp page.
I don't know whether this is correct approach or not,if not please correct me.
waiting for the reply
with regards
naresh kumar k
|
 |
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
|
|
form-bean and action-mappings are properly configured in struts-config.xml. Especially form-beans.
You must have getters and setters in your form.
What are you trying to do at line 6?
|
Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
|
 |
naresh kumar k
Ranch Hand
Joined: May 25, 2011
Posts: 30
|
|
hi Akhilesh Trivedi,
thanks for the reply. I am pretty confident that action mappings are correct and getters and setters are there in my form.
In line 6 "document.forms[0].action="CSProductsAction.do?products=fillDetails"; "
CSProductsAction is form name and products is parameter and fillDetails is method in action class
Actually i am trying call action class method using onblur() .
waiting for your reply
with regards
naresh kumar k
|
 |
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
|
|
naresh kumar k wrote:
CSProductsAction is form name and products is parameter and fillDetails is method in action class
-Which version of Struts are you on, I have used 1.1 and for me then anything like xxxxxxAction was action-name and not form form name.
-It was always 'execute' method of action where I would put my code into.
-why do you need parameters when you have an input box in place?
|
 |
naresh kumar k
Ranch Hand
Joined: May 25, 2011
Posts: 30
|
|
thanks for the quik reply
I am using struts1.3.8
here form name means jsp page form : <html:form action="CSProductsAction" method="post">
<html:text property="productName" styleClass="login-txt" onblur="javascript: fillDetails(this);" ></html:text>
</html:form>
and i tried removing parameters also but no use
waiting for reply
naresh
|
 |
naresh kumar k
Ranch Hand
Joined: May 25, 2011
Posts: 30
|
|
please any please reply on this
waiting for reply
naresh
|
 |
naresh kumar k
Ranch Hand
Joined: May 25, 2011
Posts: 30
|
|
hi
i found the answer myself i made it working by changing like below
<head>
<script type="text/javascript">
function fillDetails(value1){
document.forms[0].action="CSProductsAction.do?products=fillDetails&productName="+value1;
document.forms[0].submit();
}
</script>
</head>
<body>
<html:form action="products" method="post">
<html:text property="productName" styleClass="login-txt" onblur="javascript: fillDetails(this.value);" ></html:text>
</html:form>
|
 |
 |
|
|
subject: pass value from javascript to strutsaction class
|
|
|