Re: a simple t:if question

2010-11-11 Thread Richard Hill
In T5, 5.1 you can do something like this. In .tml:

t:if test=showTitle

  span${reportTitle}/span

  ...

  t:parameter name=else

spanNo report to display/span

  /t:parameter

/t:if


and in .java:


public boolean isShowTitle() {
   return reportId  0;
}

I believe the else syntax may have changed in T5.2.


R.



-Original Message-
From: hese 1024h...@gmail.com
Reply-to: Tapestry users users@tapestry.apache.org
To: users@tapestry.apache.org
Subject: a simple t:if question
Date: Wed, 10 Nov 2010 13:24:23 -0800 (PST)

Hi,

I am using Tapestry 5.  I see that in tapestry 4 it was possible to have
condition values in the if clause.  Is something like this available in 5?

Is it possible to check for a particular string value in the t:if tag or is
it just boolean?
I want to do something like
if(str=='somevalue') {

} else {

}

Thanks
Hese





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-11 Thread Thiago H. de Paula Figueiredo
On Thu, 11 Nov 2010 08:15:33 -0200, Richard Hill r...@su3analytics.com  
wrote:



In T5, 5.1 you can do something like this. In .tml:
t:if test=showTitle
  span${reportTitle}/span
  ...
  t:parameter name=else
spanNo report to display/span
  /t:parameter
/t:if
I believe the else syntax may have changed in T5.2.


There are now two syntaxes for passing values to parameters that are  
blocks: t:parameter name=xxx (Tapetry 5.0+) and p:xxx (Tapestry  
5.1+).


I like to write if/else's this way:

t:if test=showTitle
  span${reportTitle}/span
/t:if
t:if test=!showTitle
  spanNo report to display/span
/t:if

Better yet, using invisible instrumentation (I love my templates to look  
like HTML):


span t:type=If t:test=showTitle${reportTitle}/span
span t:type=If t:test=!showTitleNo report to display/span

Still better yet, moving all the logic to the class, as there's always a  
span:


public boolean getReportTitle() {
   return reportId  0 ? reportTitle : No report to display;
}

span${reportTitle}/span

:)

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-11 Thread Richard Hill

Excellent tips Thiago, cheers.



-Original Message-
From: Thiago H. de Paula Figueiredo thiag...@gmail.com
Reply-to: Tapestry users users@tapestry.apache.org
To: Tapestry users users@tapestry.apache.org
Subject: Re: a simple t:if question
Date: Thu, 11 Nov 2010 09:52:01 -0200

On Thu, 11 Nov 2010 08:15:33 -0200, Richard Hill r...@su3analytics.com  
wrote:

 In T5, 5.1 you can do something like this. In .tml:
 t:if test=showTitle
   span${reportTitle}/span
   ...
   t:parameter name=else
 spanNo report to display/span
   /t:parameter
 /t:if
 I believe the else syntax may have changed in T5.2.

There are now two syntaxes for passing values to parameters that are  
blocks: t:parameter name=xxx (Tapetry 5.0+) and p:xxx (Tapestry  
5.1+).

I like to write if/else's this way:

t:if test=showTitle
   span${reportTitle}/span
/t:if
t:if test=!showTitle
   spanNo report to display/span
/t:if

Better yet, using invisible instrumentation (I love my templates to look  
like HTML):

span t:type=If t:test=showTitle${reportTitle}/span
span t:type=If t:test=!showTitleNo report to display/span

Still better yet, moving all the logic to the class, as there's always a  
span:

public boolean getReportTitle() {
return reportId  0 ? reportTitle : No report to display;
}

span${reportTitle}/span

:)




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-11 Thread Christian Riedel
 public String getReportTitle()

:-)

Am 11.11.2010 um 12:52 schrieb Thiago H. de Paula Figueiredo:

 On Thu, 11 Nov 2010 08:15:33 -0200, Richard Hill r...@su3analytics.com 
 wrote:
 
 In T5, 5.1 you can do something like this. In .tml:
 t:if test=showTitle
  span${reportTitle}/span
  ...
  t:parameter name=else
spanNo report to display/span
  /t:parameter
 /t:if
 I believe the else syntax may have changed in T5.2.
 
 There are now two syntaxes for passing values to parameters that are blocks: 
 t:parameter name=xxx (Tapetry 5.0+) and p:xxx (Tapestry 5.1+).
 
 I like to write if/else's this way:
 
 t:if test=showTitle
  span${reportTitle}/span
 /t:if
 t:if test=!showTitle
  spanNo report to display/span
 /t:if
 
 Better yet, using invisible instrumentation (I love my templates to look like 
 HTML):
 
 span t:type=If t:test=showTitle${reportTitle}/span
 span t:type=If t:test=!showTitleNo report to display/span
 
 Still better yet, moving all the logic to the class, as there's always a 
 span:
 
 public boolean getReportTitle() {
   return reportId  0 ? reportTitle : No report to display;
 }
 
 span${reportTitle}/span
 
 :)
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
 instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-11 Thread Thiago H. de Paula Figueiredo
On Thu, 11 Nov 2010 09:58:42 -0200, Christian Riedel  
cr.ml...@googlemail.com wrote:



public String getReportTitle()

:-)


Yep, programming my e-mail client (Opera's M@) hasn't Java type checking .  
. . :D


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-11 Thread hese

wow! A wealth of information.  Thank you all!
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/a-simple-t-if-question-tp3259452p3260417.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



a simple t:if question

2010-11-10 Thread hese

Hi,

I am using Tapestry 5.  I see that in tapestry 4 it was possible to have
condition values in the if clause.  Is something like this available in 5?

Is it possible to check for a particular string value in the t:if tag or is
it just boolean?
I want to do something like
if(str=='somevalue') {

} else {

}

Thanks
Hese

-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/a-simple-t-if-question-tp3259452p3259452.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-10 Thread hese


...and is it possible to pass parameters into the if evaluating function and
receive a boolean/string back?

something like
if( foo('somevalue) ) {

} else {

}
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/a-simple-t-if-question-tp3259452p3259456.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-10 Thread Inge Solvoll
Short answer: No.

You have to create a public method in the page class and refer to it. All
logic should be in java, not tml.

On Wed, Nov 10, 2010 at 10:26 PM, hese 1024h...@gmail.com wrote:



 ...and is it possible to pass parameters into the if evaluating function
 and
 receive a boolean/string back?

 something like
 if( foo('somevalue) ) {

 } else {

 }
 --
 View this message in context:
 http://tapestry.1045711.n5.nabble.com/a-simple-t-if-question-tp3259452p3259456.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Re: a simple t:if question

2010-11-10 Thread hese

ok thanks!
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/a-simple-t-if-question-tp3259452p3259547.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-10 Thread Thiago H. de Paula Figueiredo

On Wed, 10 Nov 2010 19:26:18 -0200, hese 1024h...@gmail.com wrote:

...and is it possible to pass parameters into the if evaluating function  
and receive a boolean/string back?


Hi!

You pass a parameter to the If parameter (and any other parameter of any  
other component) using a binding. See  
http://tapestry.apache.org/tapestry5.1/guide/parameters.html for more  
information about bindings. If don't specify one, the default binding  
specified by the parameter is used. For the value parameter of If, the  
default binding is prop. It supports some expressions described in  
http://tapestry.apache.org/tapestry5.1/guide/propexp.html.


Anyway, follow Inge's advice, which is very wise and based: logic belongs  
in classes, not in templates. That's a bit of what MVC means.


Tapestry 4 uses OGNL as its expression binding, but Tapestry 5 has a  
deliberately less powerful expression binding due to the approach stated  
above.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-10 Thread Howard Lewis Ship
On Wed, Nov 10, 2010 at 2:21 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Wed, 10 Nov 2010 19:26:18 -0200, hese 1024h...@gmail.com wrote:

  ...and is it possible to pass parameters into the if evaluating function
 and receive a boolean/string back?


 Hi!

 You pass a parameter to the If parameter (and any other parameter of any
 other component) using a binding. See
 http://tapestry.apache.org/tapestry5.1/guide/parameters.html for more
 information about bindings. If don't specify one, the default binding
 specified by the parameter is used. For the value parameter of If, the
 default binding is prop. It supports some expressions described in
 http://tapestry.apache.org/tapestry5.1/guide/propexp.html.

 Anyway, follow Inge's advice, which is very wise and based: logic belongs
 in classes, not in templates. That's a bit of what MVC means.

 Tapestry 4 uses OGNL as its expression binding, but Tapestry 5 has a
 deliberately less powerful expression binding due to the approach stated
 above.


Less expressive, but not less powerful. T5's property expressions are
type-safe and non-reflective, with no unwanted synchronization logic, so I'd
call that a better than even trade!



 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br


 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to learn
how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: a simple t:if question

2010-11-10 Thread ael

YES...


tml 

t:if test=x x needs boolean

java

boolean x;

if(mystring.equals(tapestry))
x = true
else
x=false


Hope you understand the logic.
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/a-simple-t-if-question-tp3259452p3259618.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: a simple t:if question

2010-11-10 Thread Thiago H. de Paula Figueiredo
On Wed, 10 Nov 2010 20:56:55 -0200, Howard Lewis Ship hls...@gmail.com  
wrote:



Less expressive, but not less powerful. T5's property expressions are
type-safe and non-reflective, with no unwanted synchronization logic, so  
I'd call that a better than even trade!


I stand corrected. :)

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org