You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Antonio Gallardo <ag...@agssa.net> on 2006/08/08 07:30:10 UTC

Re: Problems with requestAttributeSelector

Hi Salvatore,

I've not used xsp for long time now, Hoeweve, IIRC, the selector is 
triggered *before* the pipeline is set, hence when the selector checks 
for the request attribute it does not exist yet. A solution is to write 
a sitemap action.

Best Regards,

Antonio Gallardo.

Salvatore Incandela escribió:
> Hi! I'm newbie to cocoon...
> I've a problem with the request attribute selector.
> Considering that i'm very unskilled...this is the problem:
>
> A login page (login.html) with a simple input form, call in the action 
> parameter ->"login" :
>  
> <form action="login" method="post">
>    <table>
>     <tr>
>          <td align="right">User:</td>
>          <td align="left"><input type="text" name="user"/></td>
>     </tr>
>     <tr>
>          <td align="right">Password:</td>
>          <td align="left"><input type="password" name="pass"/></td>
>     </tr>
>     <tr>
>          <td colspan="2" align="center"><input type="submit" 
> value="Login"/></td>
>     </tr>
>    </table>
> </form>
> ------------------------------------------------------------
> This "login" is mapped in the sitemap, the generator call login.xsp, 
> well...the login.xsp verify the pwd and username, and send by the request
> an attribute "flag" (a String that can be false or true depending if 
> the pwd is right!).
>
> <map:selectors default="browser"/>
>         <map:selectors default="request-attribute">
>             <map:selector name="request-attribute" 
> logger="sitemap.selector.request-attribute" 
> src="org.apache.cocoon.selection.RequestAttributeSelector"/>
>         </map:selectors>
>
> .
> .
> .
>     <map:match pattern="login.html">
>                 <map:read mime-type="text/html" src="content/login.html"/>
>     </map:match>
> .
> .
> .
> .          
>             <map:match pattern="login">
>                 <map:generate type="serverpages" src="xsp/login.xsp"/>
>               
>                  <map:select type="request-attribute">
>                     <map:parameter name="attribute-name" value="flag"/>
>                     <map:when test="true">
>                         <map:transform type="xslt" 
> src="style/xsl/main.xsl"/>
>                     </map:when>
>                     <map:otherwise>
>                         <map:redirect-to uri="login.html"/>
>                     </map:otherwise>
>                 </map:select>
>                 <map:serialize type="html"/>
>             </map:match>
> -------------------------------------------------------------------------------------
> the login.xsp
>
> <xsp:logic>
> String flag= new String("false");
>  String user = <xsp-request:get-parameter name="user"/>;
>  String pwd = <xsp-request:get-parameter name="pass"/>;
>
>  if (user.equals ("test") &amp;&amp; pwd.equals("a")) {
>     flag = "true";
>  } else {
>     flag= "false";
>  }
>
>   getRequest().setAttribute("flag","true");
>
>
> </xsp:logic>
> ----------------------------------------------------------------------------
> The selector appear that can't see the request's attribute, because it 
> do only the otherwise tag freely the flag value...
> There is anyone that would to help me??????


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org