Fórumok

Unable to chain struts action in a portlet

Ben Dum, módosítva 12 év-val korábban

Unable to chain struts action in a portlet

New Member Bejegyzések: 7 Csatlakozás dátuma: 2012.02.14. Legújabb bejegyzések
Hi,

I have some difficulties in creating a simple struts portlet.
The problem is that I did not manage to chain struts action (using DispatchAction and sending parameter in the URL).
So this is what I've done.

struts-config.xml :

<struts-config>
        <!-- Action Mappings -->
        <action-mappings>
                <!-- Sample Struts -->
                <action path="/view" forward="/view.jsp" validate="false" />
                <action path="/bravo" forward="/bravo.jsp" validate="false" />
                <action path="/action1" type="com.test.Action1" scope="request" parameter="param" validate="false">
                        <forward name="INIT" path="/bravo.do" redirect="false" />
                        <forward name="INIT2" path="/action2.do?param=init" redirect="false" /> 
                </action>
                <action path="/action2" type="com.test.Action2" scope="request" parameter="param" validate="false">
                		<forward name="INIT" path="/bravo.do" redirect="false" />
                </action>    
        </action-mappings>
</struts-config>


com.test.Action1.java :

public class Action1 extends DispatchAction {
	public ActionForward init(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		System.out.println("INIT");
		return (mapping.findForward("INIT"));
	}

	public ActionForward init2(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		System.out.println("INIT2");
		return (mapping.findForward("INIT2"));
	}


com.test.Action2.java :

	public ActionForward init(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception {
		System.out.println("Action2");
		return mapping.findForward("INIT");
	}


view.jsp :

	<html:link action="action1.do?param=init">init1</html:link>
	<html:link action="action1.do?param=init2">init2</html:link>



The link "init1" works contrary to the other one which chains stuts actions.

Does anyone already have this problem and solved it?

Thanks