cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <scher...@gmail.com>
Subject [c3] Implementing presentation logic in c3
Date Thu, 27 Oct 2011 22:39:41 GMT
Hi all,

what is the recommended way to implement presentation logic in c3? JX
was our former choice but I could not find it in c3. 

What should we use to implement simple presentation logic like we did
with jx? What are people using? Or do I need to migrate jx?

I tried to use the "string-template" component but I am running into a
problem when using $if(boolean)$.

I am ATM integrating Apache Shiro, a security framework that performs
authentication, authorization, cryptography, and session management,
into c3 and want to use something in the spirit of their taglibs 
<shiro:notAuthenticated>
    Please <a href="login.jsp">login</a>.
</shiro:notAuthenticated>

So what I did is I wrote a 
ShiroInterpreter implements LanguageInterpreter that can extract this info. 
However the interface LanguageInterpreter defines the return type to String.

<map:transform type="string-template">
  <map:parameter name="isUser" value="{shiro:authenticated}"/>
</map:transform>

will fail then interpreting 
$if(!isUser)$
  <a href="/logout">/logout</a>
$else$
  <a href="/login">/login</a>
$endif$

with 
...
Caused by: org.stringtemplate.v4.compiler.STException: null
	at org.stringtemplate.v4.compiler.Compiler.reportMessageAndThrowSTException(Compiler.java:213)
~[ST4-4.0.4.jar:na]

If I use only $isUser$ I get the correct value. Reading "Conditional subtemplates" [1] 
"You may only test whether an attribute is present or absent, preserving separation of model

and view. The only exception is that if an attribute value is a Boolean object, it will test
it for true/false."

So for me the exception either mean we do not support $if(condition)$ or that the compiler
do not likes that $isUser$ is a 
String and not a boolean.

TIA for any feedback!

salu2

[1] http://www.cs.usfca.edu/~parrt/course/601/lectures/stringtemplate.html
-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


Mime
View raw message