You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gunnar Eketrapp <gu...@gmail.com> on 2009/09/24 07:23:34 UTC

question

Hi!

I am converting quite a big JSP / Spring-MVC / Hibernate site to T5.

I started a week ago and I am quite amazed by T5.

It simply has made web hacking fun!

Thanks to Howard and all of you that had made this possible.

And the question is:

I often come across JSP code like ...

<c:when test="${ playersOnline > 100 }">

According to my understanding T5 does not support expressions in the test
parameter. Correct?

Now I am coding a test method in the java class for each such case. Is there
a smarter solution?

Thanks in advance!
Gunnar Eketrapp
Stockholm, Sweden

Re: Re[2]: question

Posted by Howard Lewis Ship <hl...@gmail.com>.
One size does not fit all ... that's why in Tapestry there are
different ways of accomplishing the same thing ... such as defining
component types in the template (t:component-type OR
t:type="component-type") OR in the Java class (@Component annotation).

I don't strongly object to simple expressions, such as the example,
living directly in the template, it's just not supported yet. Yes, you
can make life difficult for yourself if you use such a feature too
much. On the other hand, sometimes an expression is used just once,
and introducing machinery (a boolean getter method on the Java class)
is just so much extra work.

I want Tapestry to be pragmatic above all. I want Tapestry to be
useful to architecture astronauts (who will embrace mixins, meta
programming, annotations and byte-code manipulation) and duct-tape
programmers (who'll throw the comparisons in the template and the
Hibernate queries in the page class) and even allow both to coexist,
within reason, on the same project!

On Sat, Sep 26, 2009 at 4:07 PM, Alfonso Quiroga <al...@gmail.com> wrote:
> Wow! Sergey Kashin, you like having expressions in tml like
> "ognl:playersOnline > 100", and tomorrow can be a 600 character
> expression string, you think it's a good idea? If so, you can go back
> to struts2, where you can completely do a JSP with java scriptlets.
> But in T5 world, I prefer clean TML files, delegating to it's java
> class all this things, while having class reloading I don't have any
> problems
>
> On Sat, Sep 26, 2009 at 12:30 AM, Josh Canfield <jo...@thedailytube.com> wrote:
>>> Stop on ognl, prop is not powerful.
>>>
>>> Creating java method
>>> public boolean isSufficientPlayers() { return playersOnline > 100; }
>>> instead
>>> ognl:playersOnline > 100
>>> is not good idea
>>>
>>> 1. You move presentation in to java code
>>> 2. You lost control on viewable presentation code, 100 or 50 or 1000 palyersOnline...
>>> 3. Less usability
>>> 4. Don't wait future release of tapestry, maybe it will be in 2010 or
>>> 2011 :), but feature have needed yesterday
>>
>>
>> Hmm... I have to disagree. The method is a much better idea than using
>> inline expressions.
>>
>> 1. "playersOnline > 100" sounds a lot like business logic that may get
>> used elsewhere and changed in the next release. Do you want that
>> floating around in the template?
>>
>> 2. You now have central control of a number that is likely to change.
>> magic numbers should be avoided in your all of your code, including
>> your templates.
>>
>> 3. <t:if test="sufficientPlayers"> takes much less brain power to
>> process than the inline expression. Almost like you are documenting
>> what playersOnline > 100 is supposed to mean (was that the bonus chips
>> magic number?)
>>
>> 4. Ok, here I agree. Don't wait to code until all the features you
>> want are in the product. That's just silly...
>>
>> Josh
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@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

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


Re: Re[2]: question

Posted by Alfonso Quiroga <al...@gmail.com>.
Wow! Sergey Kashin, you like having expressions in tml like
"ognl:playersOnline > 100", and tomorrow can be a 600 character
expression string, you think it's a good idea? If so, you can go back
to struts2, where you can completely do a JSP with java scriptlets.
But in T5 world, I prefer clean TML files, delegating to it's java
class all this things, while having class reloading I don't have any
problems

On Sat, Sep 26, 2009 at 12:30 AM, Josh Canfield <jo...@thedailytube.com> wrote:
>> Stop on ognl, prop is not powerful.
>>
>> Creating java method
>> public boolean isSufficientPlayers() { return playersOnline > 100; }
>> instead
>> ognl:playersOnline > 100
>> is not good idea
>>
>> 1. You move presentation in to java code
>> 2. You lost control on viewable presentation code, 100 or 50 or 1000 palyersOnline...
>> 3. Less usability
>> 4. Don't wait future release of tapestry, maybe it will be in 2010 or
>> 2011 :), but feature have needed yesterday
>
>
> Hmm... I have to disagree. The method is a much better idea than using
> inline expressions.
>
> 1. "playersOnline > 100" sounds a lot like business logic that may get
> used elsewhere and changed in the next release. Do you want that
> floating around in the template?
>
> 2. You now have central control of a number that is likely to change.
> magic numbers should be avoided in your all of your code, including
> your templates.
>
> 3. <t:if test="sufficientPlayers"> takes much less brain power to
> process than the inline expression. Almost like you are documenting
> what playersOnline > 100 is supposed to mean (was that the bonus chips
> magic number?)
>
> 4. Ok, here I agree. Don't wait to code until all the features you
> want are in the product. That's just silly...
>
> Josh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Re[2]: question

Posted by Josh Canfield <jo...@thedailytube.com>.
> Stop on ognl, prop is not powerful.
>
> Creating java method
> public boolean isSufficientPlayers() { return playersOnline > 100; }
> instead
> ognl:playersOnline > 100
> is not good idea
>
> 1. You move presentation in to java code
> 2. You lost control on viewable presentation code, 100 or 50 or 1000 palyersOnline...
> 3. Less usability
> 4. Don't wait future release of tapestry, maybe it will be in 2010 or
> 2011 :), but feature have needed yesterday


Hmm... I have to disagree. The method is a much better idea than using
inline expressions.

1. "playersOnline > 100" sounds a lot like business logic that may get
used elsewhere and changed in the next release. Do you want that
floating around in the template?

2. You now have central control of a number that is likely to change.
magic numbers should be avoided in your all of your code, including
your templates.

3. <t:if test="sufficientPlayers"> takes much less brain power to
process than the inline expression. Almost like you are documenting
what playersOnline > 100 is supposed to mean (was that the bonus chips
magic number?)

4. Ok, here I agree. Don't wait to code until all the features you
want are in the product. That's just silly...

Josh

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


Re[2]: question

Posted by Sergey Kashin <ay...@ngs.ru>.
Stop on ognl, prop is not powerful.

Creating java method
public boolean isSufficientPlayers() { return playersOnline > 100; }
instead
ognl:playersOnline > 100
is not good idea
1. You move presentation in to java code
2. You lost control on viewable presentation code, 100 or 50 or 1000 palyersOnline...
3. Less usability
4. Don't wait future release of tapestry, maybe it will be in 2010 or
2011 :), but feature have needed yesterday

Friday, September 25, 2009, 3:39:35 AM, you wrote:

HLS> For the meantime, yes, move your code to Java code:

HLS> <t:if test="sufficientPlayers"> ...

HLS> public boolean isSufficientPlayers() { return playersOnline > 100; }

HLS> This is not so terrible because of live class reloading.

HLS> A future release of Tapestry will likely include a few more basic
HLS> comparison operators.

HLS> On Wed, Sep 23, 2009 at 11:06 PM, Kalle Korhonen
HLS> <ka...@gmail.com> wrote:
>>
>> On Wed, Sep 23, 2009 at 10:23 PM, Gunnar Eketrapp
>> <gu...@gmail.com> wrote:
>> > I often come across JSP code like ...
>> > <c:when test="${ playersOnline > 100 }">
>> > According to my understanding T5 does not support expressions in the test
>> > parameter. Correct?
>> > Now I am coding a test method in the java class for each such case. Is there
>> > a smarter solution?
>>
>> You could use ognl
>> (http://chenillekit.codehaus.org/chenillekit-tapestry/ognlbinding.html),
>> but I'd argue that coding the test method in the class is the smart
>> choice. It keeps your template clean from potentially complex logic
>> and since the changes in the page class are reloaded automatically (in
>> development mode), you don't loose anything compared to jsp.
>>
>> Kalle
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>



HLS> --
HLS> Howard M. Lewis Ship

HLS> Creator of Apache Tapestry

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

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

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




-- 
Best regards,
 Sergey                            mailto:ayrton@ngs.ru


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


Re: question

Posted by Howard Lewis Ship <hl...@gmail.com>.
For the meantime, yes, move your code to Java code:

<t:if test="sufficientPlayers"> ...

public boolean isSufficientPlayers() { return playersOnline > 100; }

This is not so terrible because of live class reloading.

A future release of Tapestry will likely include a few more basic
comparison operators.

On Wed, Sep 23, 2009 at 11:06 PM, Kalle Korhonen
<ka...@gmail.com> wrote:
>
> On Wed, Sep 23, 2009 at 10:23 PM, Gunnar Eketrapp
> <gu...@gmail.com> wrote:
> > I often come across JSP code like ...
> > <c:when test="${ playersOnline > 100 }">
> > According to my understanding T5 does not support expressions in the test
> > parameter. Correct?
> > Now I am coding a test method in the java class for each such case. Is there
> > a smarter solution?
>
> You could use ognl
> (http://chenillekit.codehaus.org/chenillekit-tapestry/ognlbinding.html),
> but I'd argue that coding the test method in the class is the smart
> choice. It keeps your template clean from potentially complex logic
> and since the changes in the page class are reloaded automatically (in
> development mode), you don't loose anything compared to jsp.
>
> Kalle
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@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

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


Re: question

Posted by Kalle Korhonen <ka...@gmail.com>.
On Wed, Sep 23, 2009 at 10:23 PM, Gunnar Eketrapp
<gu...@gmail.com> wrote:
> I often come across JSP code like ...
> <c:when test="${ playersOnline > 100 }">
> According to my understanding T5 does not support expressions in the test
> parameter. Correct?
> Now I am coding a test method in the java class for each such case. Is there
> a smarter solution?

You could use ognl
(http://chenillekit.codehaus.org/chenillekit-tapestry/ognlbinding.html),
but I'd argue that coding the test method in the class is the smart
choice. It keeps your template clean from potentially complex logic
and since the changes in the page class are reloaded automatically (in
development mode), you don't loose anything compared to jsp.

Kalle

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