Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Forwarding a JSP page in struts without population FormBean

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have to forward the control on the click of a html:button but i do not want to populate the ActionFormBean defined in the action-mapping.
One solution which i tried is to call a Java script on the click of button which will set the "action" value of form to "/ some other action-mapping "...
to be more precise i used the following code for the solution

html:form action="/Employee" focus="empName" method="POST"
input type="hidden" name="hiddenField"/
input type="hidden" name="counterValue"/
TABLE border="0" width="100%"
TR
TH align="right" Name: /TH
TD align="left" html:text property="empName"/ /TD
/TR
TR
TH align="right" Date Of Joining: /TH
TD align="left" html:text property="empJoinDate"/ (dd/MM/yyyy) (e.g. 21/03/1954) /TD
/TR
TR
TD align="right" html:button value="Submitt Button" property="SubmittButton" onKlick="onClickSubmit()"/ /TD

TD align="left" html:button value="Add" property="" onKlick="OnKlickAdd()"/
/TD /TR

on click of "add" button in calls the Java script

function OnKlickAdd()
{
document.forms[0].hiddenField.value = "add";
document.forms[0].action.value = "/AddAction";
document.forms[0].submit();
}

but the problem is that... on click of add button it doesnt go into /AddAction mapping but instead go into the /Employee mapping which is defined with html: form action="/Employee ....

i will give u guys the code which i placed in the Struts-config.xml
action
path="/AddAction"
type="org.apache.struts.actions.ForwardAction"
parameter="/EmployeeAddModify.jsp"
/action

action
path="/Employee"
type="com.employee.action.EmployeeAction"
name="employeeActionForm"
scope="request"
validate="false"
input="/EmployeeSearch.jsp"
forward
name="ADD"
path="/EmployeeAddModify.jsp"/
forward
name="success"
path="/EmployeeSearch.jsp"/
/action

I want that on click of "add" the /AddAction mapping should be used... but it is not happening...

Please help....
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be it should be

TD align="right" html:button value="Submitt Button" property="SubmittButton" onClick="onClickSubmit()"/ /TD
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
function OnKlickAdd()
{
document.forms[0].hiddenField.value = "add";
document.forms[0].action.value = "/AddAction";
document.forms[0].submit();
}


change to

function OnKlickAdd()
{
document.forms[0].hiddenField.value = "add";
document.forms[0].action.value = "/AddAction.do";
document.forms[0].submit();
}


this will help you.
 
It was the best of times. It was the worst of times. It was a tiny ad.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic