| Author |
Struts Buttons
|
Pooja Priya
Greenhorn
Joined: Jun 08, 2006
Posts: 3
|
|
Hi is it possible to display result of each button in the same page. My home page look like this welcome to home page EmpFirstname EmpDetails button data comes here when i go for Empfirstname button , i want to display data from database at data comes here place. similarly for another button. is it possible with struts. Iam new to struts. i think i have to use either javascript or lookupdispatch actions. I know how to do this work in different JSP page but i don't know how to display in a single page. iam expecting positive reply from this team. Pooja
|
 |
vidya sagar
Ranch Hand
Joined: Mar 02, 2005
Posts: 580
|
|
is it possible to display result of each button in the same page.
Yes it is possible. Have a form bean which consists of all properties that are necessary to display employee information. Once request for particular employee is requested, fetch the data from database and set in the appropriate Formbean and display in the Jsp.
|
 |
Pooja Priya
Greenhorn
Joined: Jun 08, 2006
Posts: 3
|
|
hi Many thanks for ur reply..but when iam going to display or implement then iam unable to do anything..could u please help me..now i am presenting my code here.. struts-config <struts-config> <data-sources /> <form-beans > <form-bean name="empListForm" type="com.avox.struts.form.empListForm" /> <form-bean name="ButtonsForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="empfname" type="java.util.ArrayList" /> <form-property name="empdetails" type="java.util.ArrayList" /> </form-bean> <form-bean name="DetailsForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="address" type="java.util.ArrayList" /> <form-property name="designation" type="java.util.ArrayList" /> </form-bean> </form-beans> <global-exceptions /> <global-forwards> <forward name="welcome" path="/default.do" redirect="true" /> </global-forwards> <action-mappings> <action forward="/jsp/index.jsp" path="/default" unknown="true" /> <action attribute="empListForm" input="/jsp/empList.jsp" name="empListForm" parameter="step" path="/empList" scope="request" type="com.avox.struts.action.EmpListAction" validate="false"> <forward name="showList" path="/jsp/empList.jsp" /> </action> <action attribute="ButtonsForm" input="/jsp/empList.jsp" name="ButtonsForm" parameter="method" path="/ButtonsAction" scope="request" type="com.avox.struts.action.ButtonsAction"> <forward name="button_firstname" path="/jsp/FirstName.jsp" contextRelative="true" /> <forward name="button_details" path="/jsp/Details.jsp" contextRelative="true" /> </action> <action attribute="DetailsForm" input="/jsp/Details.jsp" name="DetailsForm" parameter="method" path="/DetailsAction" scope="request" unknown="false" type="com.avox.struts.action.DetailsAction"> <forward name="button_address" path="/jsp/Details.jsp" contextRelative="true" /> <forward name="button_designation" path="/jsp/Details.jsp" contextRelative="true" /> </action> </action-mappings> <message-resources parameter="com.avox.struts.ApplicationResources" /> </struts-config> here is my JSP Firstname: <html:text property="empfname" value='<bean:write name="ButtonForm" property="empfname"/>' /> <html:form action="/DetailsAction"> <TABLE border="0" width="60%"> <TR><TD > <html:submit property="method"> <bean:message key="button.address"/> </html:submit> </TD> <TD> <html:submit property="method"> <bean:message key="button.disgnation"/> </html:submit> </TD></TR> </TABLE> </html:form> </center> Children Addresses: <CENTER><br><br> <table border="1" width="60%" rules="none"> <logic:empty name="DetailsForm" property="address" > <tr> <td> NO Children Address Available</td> </tr> </logic:empty> <logic:notEmpty name="DetailsForm" property="address" > <logic:iterate name="DetailsForm" property="address" id="address" > <tr> <td><bean:write name="address" property="address" /></td> </tr> </logic:iterate> </logic:notEmpty> </table> </CENTER> </body> </html:html> In details jsp, first i have to display firstname . below that message 2 buttons for address and disgnation below that there is a table to dispaly dat about that 2 buttons...I think u can understand my workflow. iam able to display first name at top when i click address button iam getting error can't find bean ButtonsForm ..i know why this error accured bcoz i have given forward path to Details.jsp so it is trying to execute top that is from first name(ButtonsForm).. Pooja
|
 |
vidya sagar
Ranch Hand
Joined: Mar 02, 2005
Posts: 580
|
|
<html:text property="empfname" value='<bean:write name="ButtonForm" property="empfname"/>' />
Struts tag cannot be nested Moreover whenever you are not submitting any data, dont go for submit better have a link for it. Whenever address link is clicked pass the employee id thru form bean and in your model fetch the appropriate employee address. Do the same for employee desgination
|
 |
Hema lata
Ranch Hand
Joined: Jan 24, 2005
Posts: 34
|
|
try this... set a flag on each button click. Then use if condition to check which button clicked and display respective results in same page accordingly.
|
 |
Pooja Priya
Greenhorn
Joined: Jun 08, 2006
Posts: 3
|
|
Hi if u have any sample code, could u please give that to me i have no idea about that.i already searched in google but i didn't get any right information about that. Thanks in advance. Pooja
|
 |
 |
|
|
subject: Struts Buttons
|
|
|