You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ramon Andrade <ra...@gmail.com> on 2007/07/04 16:41:21 UTC

Problem with s:action

Hy guys,

I`m trying use the tag <s:action with struts 2 but it seems that this tag
doesn`t works perfectly.

The problem is that I create a jsp that contains this tag <s:action>. The
param 'name' of this tag contains the name of a action that I create. The
result of this action redirect to a jsp that contains a combobox populated
with a iterator.

The problem is that, when the first page is loaded the content of the jsp
that is loaded by the s:action doesn`t is shown, but by debug I saw that the
action calling by tag s:action is performed but seems that the action do't
redirect to jsp result. And has also one more thing that i dont understand,
the param that I pass in s:action dont came setup it`s always null. 

Follow my jsp that contains <s:action>.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib prefix="s" uri="/tags/struts-tags" %>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;">
</head>
<body bgcolor="#FFFFFF" leftmargin="10" topmargin="10" marginwidth="5"
marginheight="5">
	<s:form action="cadastrarUsuario.ssp" method="post" name="cadastrarForm">
		<table width="600" border="0" cellspacing="0" cellpadding="0">
                     <tr>
			<td class=td_campo>
				<s:action name="buscarSessaoFiltrada" executeResult="true">
				          <s:param id="'inicial'" name="'inicial'"
value="'A'"></s:param>
				</s:action>
			</td>
		     </tr>
		</table>
	</s:form>
</body>
</html>

Follow the result(jsp) from action (sessionFilter) calling by <s:action>:

<%@ taglib prefix="s" uri="/tags/struts-tags" %>
<div id ="sessaoFiltro">
<select name="sessoes" size="7" style="width: 270px" multiple="multiple">
	<s:if test="sessions">
		<s:iterator value="sessions">
			<option value="<s:property value="id"/>"><s:property value="nome"
/></option>
		</s:iterator>
	</s:if>
</select>
</div>

Follow part of my struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
	<constant name="struts.objectFactory" value="spring" />
    <constant name="struts.devMode" value="true" />

    ...

    <include file="struts-default.xml"/>
    <package name="person" extends="struts-default">
             ...

        <action name="buscarSessaoFiltrada"
class="com.globo.contcma.controller.admin.sessao.BuscarSessaoFiltradaAction"> 
            <interceptor-ref name="timer"/>
            <interceptor-ref name="defaultStack"/>
            <result name="success"
type="dispatcher">admin/sessao/glb_contcma_sessao_filtrar.jsp</result> 
            <result name="error"
type="dispatcher">admin/sessao/glb_contcma_sessao_filtrar.jsp</result>
        </action>
    </package>
</struts>

I`m doing or configuring something wrong? Is missing some interceptor?

Any help is welcome.

Thanks all.

-- 
View this message in context: http://www.nabble.com/Problem-with-s%3Aaction-tf4024697.html#a11431787
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with s:action

Posted by adailey14 <ad...@gmail.com>.
Hi,

I was having the same problem. The issue is for some reason the results are
being searched for relative to the JSP rather than relative to the request
context. To fix it, change your action in the struts.xml file to have a
slash "/" at the beginning:

<action name="buscarSessaoFiltrada"
class="com.globo.contcma.controller.admin.sessao.BuscarSessaoFiltradaAction">
      <interceptor-ref name="timer"/>
      <interceptor-ref name="defaultStack"/>
      <result name="success"
type="dispatcher">/admin/sessao/glb_contcma_sessao_filtrar.jsp</result>
      <result name="error"
type="dispatcher">/admin/sessao/glb_contcma_sessao_filtrar.jsp</result>
</action> 

Hope this helps.



Ramon Andrade wrote:
> 
> Hy guys,
> 
> I`m trying use the tag <s:action with struts 2 but it seems that this tag
> doesn`t works perfectly.
> 
> The problem is that I create a jsp that contains this tag <s:action>. The
> param 'name' of this tag contains the name of a action that I create. The
> result of this action redirect to a jsp that contains a combobox populated
> with a iterator.
> 
> The problem is that, when the first page is loaded the content of the jsp
> that is loaded by the s:action doesn`t is shown, but by debug I saw that
> the action calling by tag s:action is performed but seems that the action
> do't redirect to jsp result. And has also one more thing that i dont
> understand, the param that I pass in s:action dont came setup it`s always
> null. 
> 
> Follow my jsp that contains <s:action>.
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <%@ taglib prefix="s" uri="/tags/struts-tags" %>
> <html>
> <head>
> 	<meta http-equiv="Content-Type" content="text/html;">
> </head>
> <body bgcolor="#FFFFFF" leftmargin="10" topmargin="10" marginwidth="5"
> marginheight="5">
> 	<s:form action="cadastrarUsuario.ssp" method="post" name="cadastrarForm">
> 		<table width="600" border="0" cellspacing="0" cellpadding="0">
>                      <tr>
> 			<td class=td_campo>
> 				<s:action name="buscarSessaoFiltrada" executeResult="true">
> 				          <s:param id="'inicial'" name="'inicial'"
> value="'A'"></s:param>
> 				</s:action>
> 			</td>
> 		     </tr>
> 		</table>
> 	</s:form>
> </body>
> </html>
> 
> Follow the result(jsp) from action (sessionFilter) calling by <s:action>:
> 
> <%@ taglib prefix="s" uri="/tags/struts-tags" %>
> <div id ="sessaoFiltro">
> <select name="sessoes" size="7" style="width: 270px" multiple="multiple">
> 	<s:if test="sessions">
> 		<s:iterator value="sessions">
> 			<option value="<s:property value="id"/>"><s:property value="nome"
> /></option>
> 		</s:iterator>
> 	</s:if>
> </select>
> </div>
> 
> Follow part of my struts.xml
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
>     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>     "http://struts.apache.org/dtds/struts-2.0.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="spring" />
>     <constant name="struts.devMode" value="true" />
> 
>     ...
> 
>     <include file="struts-default.xml"/>
>     <package name="person" extends="struts-default">
>              ...
> 
>         <action name="buscarSessaoFiltrada"
> class="com.globo.contcma.controller.admin.sessao.BuscarSessaoFiltradaAction"> 
>             <interceptor-ref name="timer"/>
>             <interceptor-ref name="defaultStack"/>
>             <result name="success"
> type="dispatcher">admin/sessao/glb_contcma_sessao_filtrar.jsp</result> 
>             <result name="error"
> type="dispatcher">admin/sessao/glb_contcma_sessao_filtrar.jsp</result>
>         </action>
>     </package>
> </struts>
> 
> I`m doing or configuring something wrong? Is missing some interceptor?
> 
> Any help is welcome.
> 
> Thanks all.
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-s%3Aaction-tf4024697.html#a11735608
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org