File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Forwarding a JSP page in struts without population FormBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Forwarding a JSP page in struts without population FormBean" Watch "Forwarding a JSP page in struts without population FormBean" New topic
Author

Forwarding a JSP page in struts without population FormBean

Ankit Pradhan
Greenhorn

Joined: Jan 05, 2005
Posts: 16
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....
gayathri hariharan
Greenhorn

Joined: Jan 11, 2005
Posts: 27
May be it should be

TD align="right" html:button value="Submitt Button" property="SubmittButton" onClick="onClickSubmit()"/ /TD


thanks,<br />Gayathri
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
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.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forwarding a JSP page in struts without population FormBean
 
Similar Threads
page redirecting problem!
Verification failed on Username existence check using AJAX
SuccessView isn't set
INDEX PROPERTY <html:form> with nested beans
form bean value not getting