Ads 468x60px

Pages

Sabtu, 22 Februari 2014

Any Struts 1 Experts Out There

There are several JSPs that share some forms, but not others. The first of these, w_psi_s1_11.jsp (great name, what?) has access to offenderEmploymentForm. From this JSP, we call an action method OffenderEmployment.editEmployer. This action method transfers control to w_psi_s1_16.jsp (another great name), which has access to offenderEmploymentForm and employerSearchForm. The user hits the add button, which does a submit over to action method OffenderEmploymentAction.findEmployer. (Yes, the class is not the same as the other action method that I have already mentioned.) The findEmployer action method transfers control to w_psi_s1_14.jsp, where the user gets to add a new employer to the list. This JSP also has access to offenderEmploymentForm -- however, the action method that it calls on save, EmployerAction.save, does not have access to offenderEmploymentForm.

The problem is that when the submit on this last JSP happens, I need to update the employerId field in offenderEmploymentForm. I have the employerId visible in the JSP, but it does no good to pass it to the EmployerAction.save action method, because that class does not have access to the session form offenderEmploymentForm. I can read offenderEmploymentForm.employerId from the JSP -- but how do I write it from the JSP?

I have looked at a variety of methods around this. I thought that I could pass the offenderEmploymentForm using setAttribute in the JSP and getAttribute in the EmployerAction.save method -- but no, Struts 1 cant pass objects, and I really need to to update the existing session offenderEmploymentForm.

Our Struts expert is out sick, and I am running out of strings to Google to solve this.

UPDATE: I found a solution, but it was not very pretty.  I now understand how you switch from one action block to another.  The trick was to switch from the findEmployer action to the offenderEmployer action, invoking an action method in the offenderEmployer action.  Also, request.setParameter("employerId", the Form.getEmployerId()); in the action method from where I was forwarding, and request.getParameter("employerId") in the receiving action method.  Ugly.

Related Posts by Categories

0 komentar:

Posting Komentar