こんにちは、少し助けが必要です。
私はSpringとポートレットを使用しています.私の問題は、2つのBeanを持つ2つの異なるコントローラーによって2つのタブが処理されることです. 必要なのは、2 番目のコントローラーのレンダリング段階で、最初のコントローラーの Bean からのデータを表示することです。
私は次のようにしようとします:
これは、必要な値を収集し、それらを使用してリクエストを生成する最初のタブのコントローラーです。
@Controller
@RequestMapping(ServletContextKeys.SC_VIEW_MODE)
//This is my bean session
@SessionAttributes(salarioBean)
public class AltaSalarioFSOPortletController extends BaseController {
private SalarioBean salarioBean;
//With this method generated the request to display the data in the other controller jsp
@RequestMapping(params = ACTION_CAMBIA_TAB)
public final String doRenderTab(@ModelAttribute(value = "SalarioBean") SalarioBean salario, Errors errors, RenderRequest renderrequest, PortletSession portletSession) {
//retrieve the bean managed by Spring in session
SalarioBean salarioSessionBean = (SalarioBean) portletSession.getAttribute(salarioBean);
ImputacionBean imputacionBean = new ImputacionBean();
....Insert data on imputacionBean
//generated the request to display data in jsp handled by another controller
renderrequest.setAttribute(imputacionBean,imputacionBean);
//redirected to jsp
return jsp_tab2;
}
このコントローラーを使用してjspでデータを表示しますが、他のタブをクリックしたときに同じデータを生成しようとすると問題が発生します。そこで、別のコントローラーでこのメソッド render を実行しようとしました:
@Controller
@RequestMapping(ServletContextKeys.SC_VIEW_MODE)
@SessionAttributes(imputacionBean)
public class AsociarCostesSalarioAlumnoPortletController extends BaseController {
private ImputacionBean imputacionBean;
@RequestMapping(params = ACTION_ASOC_COSTES_SALARIO)
public final String doRender(@ModelAttribute(value = "ImputacionBean") ImputacionBean imputacionSalarioAlumno,Errors errors, RenderRequest renderrequest,SessionStatus status) {
justifSessionBean = (SalarioBean) renderrequest.getPortletSession().getAttribute(salarioBean);
ImputacionBean imp=(ImputacionBean) justifSessionBean.getImputaciones().get(0);
renderrequest.getPortletSession().setAttribute(imputacionBean,imp);
setJustificanteAsociarCostesSalarioAlumno(imp);
setRequestParameters(renderrequest, imp);
return jsp_tab2;
}
@Override
public final void setRequestParameters(RenderRequest renderrequest, Object object) {
ImputacionBean imputacionSalarioAlumno = (ImputacionBean) object;
renderrequest.setAttribute(imputacionBean, imputacionSalarioAlumno);
renderrequest.getPortletSession().setAttribute(imputacionBean,imputacionSalarioAlumno);
}
public final void setJustificanteAsociarCostesSalarioAlumno(ImputacionBean imputacionSalario) {
this.imputacionBean = imputacionSalario;
}
スプリングを処理する Bean が初めてオブジェクトが空になったとき。私の質問は、最初のコントローラーから Spring を処理するセッション Bean を設定するにはどうすればよいですか? したがって、リクエストを生成するとき、この Bean にはデータが含まれます。
このデータを使用して新しいリクエストを生成するには、Spring を処理する Bean を変更する必要があります。
助けてくれてありがとう。わからないところがあれば、丁寧に説明してくれます。