Hi Ranchers,
I normal circumstances i uesd to call approriate method in dispatchAction class using hidden attribute in
jsp page,but for this case i dont know how to handle.
I have created a DispatchAction class.
my reqiurement is that when i click on getDetails link on the jsp page,the following getPatientDetails() method should be executed in DispatchAction class and a new page must be populated wiith details..
<html:link forward="PatientDetails">get Details</html:link>
here is my strust-config.xml
----------------------------
<global-forwards>
<forward
name="PatientDetails"
path="/PatientDetails.do"/>
</global-forwards>
<action-mappings>
<action
path="/PatientDetails"
type="ssl.phr.patientdemographics.actionservlet.PatientAction"
name="PatientDetailsForm"
scope="request"
validate="true"
parameter="action"
input="/patientregistration.jsp">
<forward name="success" path="/patientregistrationcard.jsp"/>
<forward name="patientdetails" path="/patientdetails.jsp"/>
</action>
</action-mappings>
------------------------------
here is my
import ssl.phr.patientdemographics.dto.*;
import ssl.phr.patientdemographics.dao.*;
import java.io.*;import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import javax.servlet.http.HttpSession ;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.http.HttpServlet;
public final class PatientAction extends DispatchAction {
public static
String SUCCESS = "success";
public static String Patientdetials = "patientdetails";
public ActionForward PRegistration(ActionMapping mapping,
ActionForm form,HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("inside perform method");
PatientDetailsForm pdform =(PatientDetailsForm) form;
PatientDetailsDAO dao= new PatientDetailsDAO();
String pfirstname=request.getParameter("firstName");
pfirstname=pfirstname.replace("'","''");
pdform.setDateOfBirth("");//request.getParameter("dob")
String zip=request.getParameter("zipCode");
int z=Integer.parseInt(zip);
pdform.setZipCode(z);
String emergencyKey=dao.insertPatientRegistrationRecord(pdform);
request.setAttribute("EKey",emergencyKey);
request.setAttribute("PatientDetails",pdform);
return mapping.findForward(SUCCESS);
} // end PatientRegistration
public ActionForward getPatientDetails(ActionMapping mapping,
ActionForm form,HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException {
HttpSession session = request.getSession();
//int patientID;
String userName=(String)session.getAttribute("userName");
int pid=((Integer)session.getAttribute("patientID")).intValue();
System.out.println("username is.. "+userName);
System.out.println("pid is.. "+pid);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("inside perform method");
PatientDetailsForm pdform =(PatientDetailsForm) form;
pdform=(PatientDetailsForm)patdao.retrieveRecord(pid);
return mapping.findForward(Patientdetials);
}
}
help me out
Thanks