You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Chris Meyer <cm...@ultratask.com> on 2000/10/26 02:02:49 UTC

extending ProducerFromFile functionality

Hi,

When an page request comes into Cocoon 1.8, it is typically passed on 
to a ProducerFromFile object which loads the template from a file 
after which further processing is applied.

I'm looking for a way to 'produce' a different template file based on 
the request parameters.

For instance, let's say I'm trying to protect a document by requiring 
the user to log in first.

The user may request something like 'http://mysite.com/cocoon/protected.html'.

I can check to see whether they've logged in and then 'redirect' them 
to a login page if they haven't. But this isn't a wholly satisfying 
solution for many reasons.

What I think it would be ideal is if I could process the request and 
'produce' a template file based on the request parameters... If they 
were logged in, it would 'produce' the file 'protected.html'; 
otherwise it might 'produce' the file 'pleaselogin.html'.

The STRUTS framework, at its most basic level, does just this. It 
seems like it would be a nice addition to Cocoon and allow processing 
of Actions...

------------------
MY QUESTIONS: should I write a custom producer to do this? is this 
something that others could use? is this what Cocoon 2 already does?
------------------

Chris

Re: What is the &&(java) within XSL.

Posted by Matthew Cordes <mc...@maine.edu>.
I would do:

if ( <xsl:value-of select="string(//bodytext/setdatum/set)"/>
		&amp;&amp; !<xsl:value-of select="string(//bodytext/setzeit/set)"/>
		)
		{
			// do stuff

		}

This should work assuming the set node can only have values of 		
'true' or 'false'. 


Your xsl test is pretty close it would be

<xsl:if 
	test="//bodytext/setdatum/set = 'true' and //bodytext/setzeit/set  = 'false'"
>
	// do stuff

</xsl:if>	

You may also want to replace set with set[1] if you just want to 
test the first set found for  true/falseness.  As I recally comparing
a nodeset to a string checks to see if any node in that set is equal 
to the string, but I could be wrong.
	
Disclaimer - this is all untested, and I am certainly as error prone
as the next.

-matt

On Thu, Oct 26, 2000 at 09:40:19AM +0200, Rob van der Zeijden wrote:
> I want to test two variables. The test in java would be
> if (//bodytext/setdatum/set == true && //bodytext/setzeit/set == false)
> 
> Is this test also possible within XSL. The test would proberly a bit look
> like:
> 
>       <xsl:if test="//bodytext/setdatum/set = 'true' &&
> //bodytext/setzeit/set  = 'false'">
> 
> But cocoon does not like the &&s.
> 
> Thanks.
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 

What is the &&(java) within XSL.

Posted by Rob van der Zeijden <r....@tiscon.de>.
I want to test two variables. The test in java would be
if (//bodytext/setdatum/set == true && //bodytext/setzeit/set == false)

Is this test also possible within XSL. The test would proberly a bit look
like:

      <xsl:if test="//bodytext/setdatum/set = 'true' &&
//bodytext/setzeit/set  = 'false'">

But cocoon does not like the &&s.

Thanks.





Re: extending ProducerFromFile functionality

Posted by Ulrich Mayring <ul...@denic.de>.
Chris Meyer wrote:
> 
> >The auth taglib does this. Download it under
> >http://ulim.cocoonhost.com/auth.tar.gz
> 
> This may work for authentication, but I'm concerned about the more
> general case of simply 'needing more information from the user to
> proceed'.
> 
> For example, I may have just added a product to a shopping cart and
> want to display the shopping cart, but the shopping cart may
> determine that more information is needed to add a particular item,
> so it would redirect the user to a page requesting more information...

The auth taglib implements just this behavior. For example, a user may
request a page, which he is not authenticated for. He gets redirected to
the login page with a message "please log in first before accessing
protected data". At the login page he may enter his password wrong, so
he gets redirected to the login page with a message "authentication
failed". If he logs in successfully he is redirected to a success page.
All done with very simple XSP :)

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

Re: extending ProducerFromFile functionality

Posted by Chris Meyer <cm...@ultratask.com>.
>Chris Meyer wrote:
>>
>>  For instance, let's say I'm trying to protect a document by requiring
>>  the user to log in first.
>
>The auth taglib does this. Download it under
>http://ulim.cocoonhost.com/auth.tar.gz

This may work for authentication, but I'm concerned about the more 
general case of simply 'needing more information from the user to 
proceed'.

For example, I may have just added a product to a shopping cart and 
want to display the shopping cart, but the shopping cart may 
determine that more information is needed to add a particular item, 
so it would redirect the user to a page requesting more information...

>  > The user may request something like 
>'http://mysite.com/cocoon/protected.html'.
>>
>>  I can check to see whether they've logged in and then 'redirect' them
>>  to a login page if they haven't. But this isn't a wholly satisfying
>>  solution for many reasons.
>
>Please list a few. I've successfully used the auth taglib for exactly
>this application and it works very well in my case. If you have any
>suggestions on how to improve it, I'd be grateful to hear them.
>
>Ulrich

Re: extending ProducerFromFile functionality

Posted by Ulrich Mayring <ul...@denic.de>.
Chris Meyer wrote:
> 
> For instance, let's say I'm trying to protect a document by requiring
> the user to log in first.

The auth taglib does this. Download it under
http://ulim.cocoonhost.com/auth.tar.gz

> The user may request something like 'http://mysite.com/cocoon/protected.html'.
> 
> I can check to see whether they've logged in and then 'redirect' them
> to a login page if they haven't. But this isn't a wholly satisfying
> solution for many reasons.

Please list a few. I've successfully used the auth taglib for exactly
this application and it works very well in my case. If you have any
suggestions on how to improve it, I'd be grateful to hear them.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung