Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Set values in JSP

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I use struts 1.0 ,WL 8 and Win2000.

How do I copy the javascript variable into the ActionForm field ??

Say , I have a page adminConsole.jsp and adminConsoleForm.java. I want to copy the value of the java script variable into the field (member) of the class "adminConsoleForm".

I guess I can use html:hidden but I am having trouble setting this values.
Two questions:

1.Could anybody give a small piece of work code ?
2. How do I change the value of actionForm field in JSP page ???

Thanks all
-Anand.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you trying to do this? Please explain your example.
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say,
I have a grid. I got this grid code from ActiveWidget.I don't have luxury of doing much with ActiveWidget because it's a huge code.

1.I would select the line from the grid and press "delete".
2.I would get the value of that line in the javascript variable.
3.Once I get this value , i would pass it on to the actionForm ( only after submission of the form though). And then action class can get this value and delete the line.

thanks
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The important thing to understand about <html:xxx> tags is that they render to standard html <input> tags. As such they can be manipulated by javascript just as any standard html can be manipulated.

here is a short example:

<html:form name="MyForm" type="forms.MyForm" scope="request" action="myProcess" method="post" onsubmit="document.MyForm.foo.value='New Value'">
<html:hidden name="MyForm" property="foo"/>
<P>Foo: <bean:write name="My" property="foo"/><BR>Bar: <bean:write name="MyForm" property="bar"/>
</P>
<html:submit value="Submit Form" />
</html:form>

In this example, the <html:hidden> tag will be rendered to:

<input type="hidden" name="foo" value="Foo Value">

The name attribute in the <input> tag will translate to the property attribute specified in the struts <html:hidden> tag.

In the above example, the value of foo will be changed to "New value" when the form is submitted using the onSubmit attribute of the form, but the same javascript code could be executed at any point.

Once you have set the value of the hidden field, Struts will take care of populating the Form bean. Struts does this simply by using the name on the form. It sees that the name of the hidden input field is "foo" and then executes the setFoo() method on the form bean, passing the value from the page as a parameter.

Merrill
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to to forward a jsp to other jsp at the same time i want to push the image to some other jsp
 
Oh the stink of it! Smell my tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic