You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by dwi ardi irawan <pe...@gmail.com> on 2009/03/14 09:19:02 UTC

Q : IF component in tapestry 5 ?

guys, i'm so stress with "if" komponent. how to use it
here's my code


.tml
===========================================

<t:select t:id="chartType" onchange="this.form.submit()"/>

    <t:if test="dailyChart">
    AAA
    </t:if>


    <t:if test="monthlyChart">
    BBB
    </t:if>

    <t:if test="yearlyChart">
    CCC
    </t:if>

=============================================

.java
=============================================

   @Persist
    private ChartType chartType;

    public ChartType getChartType() {
        return chartType;
    }

    @Property
    private String dailyChart, monthlyChart, yearlyChart;

   Object onSuccessFromChartForm(){

        if(chartType==ChartType.DAILY){
            dailyChart = "D";
            monthlyChart = null;
            yearlyChart = null;
        }else if (chartType==ChartType.MONTHLY) {
            dailyChart = null;
            monthlyChart = "M";
            yearlyChart = null;
        }else if (chartType==chartType.YEARLY) {
            dailyChart = null;
            monthlyChart = null;
            yearlyChart = "Y";
        }



if we look the code above, it should work but it doesn't
when i choose "Daily" on select menu that means dailyChart property will
become "D" and it should render this block and output "AAA"
<t:if test="dailyChart">
    AAA
    </t:if>

is there something wrong wih my code or my perception of if component in
tapestry 5


thnx u

dwi ardi irawan - 'penyihirkecil'
http://www.dwiardiirawan.com <http://dwiardiirawan.blogspot.com/>

Re: Q : IF component in tapestry 5 ?

Posted by Andy Pahne <an...@googlemail.com>.
Ulrich Stärk schrieb:
> The test will be true if the provided test returns true or in case of 
> an object return type that object is not null.
Or a collection which is not empty.

What about arrays? True, if array is not null, true, if array.size > 0? 
I am not sure...


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


Re: Q : IF component in tapestry 5 ?

Posted by dwi ardi irawan <pe...@gmail.com>.
thnx u. it works now
-- 
http://www.dwiardiirawan.com
"cos everyone could be extraordinary...lighten up !"

Re: Q : IF component in tapestry 5 ?

Posted by Luther Baker <lu...@gmail.com>.
I believe that setting your chart type Strings in a SUBMIT event handler
without persisting them - effectively does nothing for you. They will be
reset to null before the successive page sees them.

Unless you set your chart type in a "PRE" event of the successive page
(onActivate ...) - I believe you'll need to @Persist your chart types ..

Something like:

@Persist
 @Property
private String dailyChart, monthlyChart, yearlyChart;

Make sure @Persist and @Property apply to all the relevant Strings.

-Luther



On Sat, Mar 14, 2009 at 1:26 PM, Ulrich Stärk <ul...@spielviel.de> wrote:

> The test will be true if the provided test returns true or in case of an
> object return type that object is not null.
>
> Uli
>
> Alex Kotchnev schrieb:
>
>  w/o looking at the docs, my impression is that the 'test' attribute of
>> t:if expects a boolean value. Neither of daily,monthly,and yearly
>> chart props are boolean.
>>
>> On 3/14/09, dwi ardi irawan <pe...@gmail.com> wrote:
>>
>>> guys, i'm so stress with "if" komponent. how to use it
>>> here's my code
>>>
>>>
>>> .tml
>>> ===========================================
>>>
>>> <t:select t:id="chartType" onchange="this.form.submit()"/>
>>>
>>>    <t:if test="dailyChart">
>>>    AAA
>>>    </t:if>
>>>
>>>
>>>    <t:if test="monthlyChart">
>>>    BBB
>>>    </t:if>
>>>
>>>    <t:if test="yearlyChart">
>>>    CCC
>>>    </t:if>
>>>
>>> =============================================
>>>
>>> .java
>>> =============================================
>>>
>>>   @Persist
>>>    private ChartType chartType;
>>>
>>>    public ChartType getChartType() {
>>>        return chartType;
>>>    }
>>>
>>>    @Property
>>>    private String dailyChart, monthlyChart, yearlyChart;
>>>
>>>   Object onSuccessFromChartForm(){
>>>
>>>        if(chartType==ChartType.DAILY){
>>>            dailyChart = "D";
>>>            monthlyChart = null;
>>>            yearlyChart = null;
>>>        }else if (chartType==ChartType.MONTHLY) {
>>>            dailyChart = null;
>>>            monthlyChart = "M";
>>>            yearlyChart = null;
>>>        }else if (chartType==chartType.YEARLY) {
>>>            dailyChart = null;
>>>            monthlyChart = null;
>>>            yearlyChart = "Y";
>>>        }
>>>
>>>
>>>
>>> if we look the code above, it should work but it doesn't
>>> when i choose "Daily" on select menu that means dailyChart property will
>>> become "D" and it should render this block and output "AAA"
>>> <t:if test="dailyChart">
>>>    AAA
>>>    </t:if>
>>>
>>> is there something wrong wih my code or my perception of if component in
>>> tapestry 5
>>>
>>>
>>> thnx u
>>>
>>> dwi ardi irawan - 'penyihirkecil'
>>> http://www.dwiardiirawan.com <http://dwiardiirawan.blogspot.com/>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Q : IF component in tapestry 5 ?

Posted by Ulrich Stärk <ul...@spielviel.de>.
The test will be true if the provided test returns true or in case of an object return type that 
object is not null.

Uli

Alex Kotchnev schrieb:
> w/o looking at the docs, my impression is that the 'test' attribute of
> t:if expects a boolean value. Neither of daily,monthly,and yearly
> chart props are boolean.
> 
> On 3/14/09, dwi ardi irawan <pe...@gmail.com> wrote:
>> guys, i'm so stress with "if" komponent. how to use it
>> here's my code
>>
>>
>> .tml
>> ===========================================
>>
>> <t:select t:id="chartType" onchange="this.form.submit()"/>
>>
>>     <t:if test="dailyChart">
>>     AAA
>>     </t:if>
>>
>>
>>     <t:if test="monthlyChart">
>>     BBB
>>     </t:if>
>>
>>     <t:if test="yearlyChart">
>>     CCC
>>     </t:if>
>>
>> =============================================
>>
>> .java
>> =============================================
>>
>>    @Persist
>>     private ChartType chartType;
>>
>>     public ChartType getChartType() {
>>         return chartType;
>>     }
>>
>>     @Property
>>     private String dailyChart, monthlyChart, yearlyChart;
>>
>>    Object onSuccessFromChartForm(){
>>
>>         if(chartType==ChartType.DAILY){
>>             dailyChart = "D";
>>             monthlyChart = null;
>>             yearlyChart = null;
>>         }else if (chartType==ChartType.MONTHLY) {
>>             dailyChart = null;
>>             monthlyChart = "M";
>>             yearlyChart = null;
>>         }else if (chartType==chartType.YEARLY) {
>>             dailyChart = null;
>>             monthlyChart = null;
>>             yearlyChart = "Y";
>>         }
>>
>>
>>
>> if we look the code above, it should work but it doesn't
>> when i choose "Daily" on select menu that means dailyChart property will
>> become "D" and it should render this block and output "AAA"
>> <t:if test="dailyChart">
>>     AAA
>>     </t:if>
>>
>> is there something wrong wih my code or my perception of if component in
>> tapestry 5
>>
>>
>> thnx u
>>
>> dwi ardi irawan - 'penyihirkecil'
>> http://www.dwiardiirawan.com <http://dwiardiirawan.blogspot.com/>
>>
> 


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


Re: Q : IF component in tapestry 5 ?

Posted by Alex Kotchnev <ak...@gmail.com>.
w/o looking at the docs, my impression is that the 'test' attribute of
t:if expects a boolean value. Neither of daily,monthly,and yearly
chart props are boolean.

On 3/14/09, dwi ardi irawan <pe...@gmail.com> wrote:
> guys, i'm so stress with "if" komponent. how to use it
> here's my code
>
>
> .tml
> ===========================================
>
> <t:select t:id="chartType" onchange="this.form.submit()"/>
>
>     <t:if test="dailyChart">
>     AAA
>     </t:if>
>
>
>     <t:if test="monthlyChart">
>     BBB
>     </t:if>
>
>     <t:if test="yearlyChart">
>     CCC
>     </t:if>
>
> =============================================
>
> .java
> =============================================
>
>    @Persist
>     private ChartType chartType;
>
>     public ChartType getChartType() {
>         return chartType;
>     }
>
>     @Property
>     private String dailyChart, monthlyChart, yearlyChart;
>
>    Object onSuccessFromChartForm(){
>
>         if(chartType==ChartType.DAILY){
>             dailyChart = "D";
>             monthlyChart = null;
>             yearlyChart = null;
>         }else if (chartType==ChartType.MONTHLY) {
>             dailyChart = null;
>             monthlyChart = "M";
>             yearlyChart = null;
>         }else if (chartType==chartType.YEARLY) {
>             dailyChart = null;
>             monthlyChart = null;
>             yearlyChart = "Y";
>         }
>
>
>
> if we look the code above, it should work but it doesn't
> when i choose "Daily" on select menu that means dailyChart property will
> become "D" and it should render this block and output "AAA"
> <t:if test="dailyChart">
>     AAA
>     </t:if>
>
> is there something wrong wih my code or my perception of if component in
> tapestry 5
>
>
> thnx u
>
> dwi ardi irawan - 'penyihirkecil'
> http://www.dwiardiirawan.com <http://dwiardiirawan.blogspot.com/>
>

-- 
Sent from my mobile device

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


Re: IF component in tapestry 5 ?

Posted by dwi ardi irawan <pe...@gmail.com>.
thnx u for the information....^_^v

Re: IF component in tapestry 5 ?

Posted by ningdh <ni...@gmail.com>.
Hi,

Refer here: http://tapestry.formos.com/nightly/tapestry5/guide/persist.html

Flash field would live in the session not a long time, and will be removed from session after next request (the one after post).

DH
----- Original Message ----- 
From: "dwi ardi irawan" To:
 "Tapestry users" <us...@tapestry.apache.org>
Sent: Saturday, March 14, 2009 9:25 PM
Subject: Re: IF component in tapestry 5 ?


> @Persist("flash")
> 
> what does "flash" mean ??
>

Re: IF component in tapestry 5 ?

Posted by dwi ardi irawan <pe...@gmail.com>.
@Persist("flash")

what does "flash" mean ??

Re: IF component in tapestry 5 ?

Posted by dwi ardi irawan <pe...@gmail.com>.
It Works.....Thnx you

-- 
http://www.dwiardiirawan.com
"cos everyone could be extraordinary...lighten up !"

Re: IF component in tapestry 5 ?

Posted by ningdh <ni...@gmail.com>.
This is not an issueof If component, but due to redirect after post.

In your case, because private String dailyChart, monthlyChart, yearlyChart are not persisted and not in the activation context,
they will be set to default value null.

Solution: add flash persistent strategy like following and have a try:

@Persist("flash")
@Property
private String dailyChart, monthlyChart, yearlyChart ;

Thanks,
DH

----- Original Message ----- 
From: "dwi ardi irawan" 
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Saturday, March 14, 2009 4:19 PM
Subject: Q : IF component in tapestry 5 ?


> guys, i'm so stress with "if" komponent. how to use it
> here's my code
> 
> 
> .tml
> ===========================================
> 
> <t:select t:id="chartType" onchange="this.form.submit()"/>
> 
>    <t:if test="dailyChart">
>    AAA
>    </t:if>
> 
> 
>    <t:if test="monthlyChart">
>    BBB
>    </t:if>
> 
>    <t:if test="yearlyChart">
>    CCC
>    </t:if>
> 
> =============================================
> 
> .java
> =============================================
> 
>   @Persist
>    private ChartType chartType;
> 
>    public ChartType getChartType() {
>        return chartType;
>    }
> 
>    @Property
>    private String dailyChart, monthlyChart, yearlyChart;
> 
>   Object onSuccessFromChartForm(){
> 
>        if(chartType==ChartType.DAILY){
>            dailyChart = "D";
>            monthlyChart = null;
>            yearlyChart = null;
>        }else if (chartType==ChartType.MONTHLY) {
>            dailyChart = null;
>            monthlyChart = "M";
>            yearlyChart = null;
>        }else if (chartType==chartType.YEARLY) {
>            dailyChart = null;
>            monthlyChart = null;
>            yearlyChart = "Y";
>        }
> 
> 
> 
> if we look the code above, it should work but it doesn't
> when i choose "Daily" on select menu that means dailyChart property will
> become "D" and it should render this block and output "AAA"
> <t:if test="dailyChart">
>    AAA
>    </t:if>
> 
> is there something wrong wih my code or my perception of if component in
> tapestry 5
> 
> 
> thnx u
> 
> dwi ardi irawan - 'penyihirkecil'
> http://www.dwiardiirawan.com <http://dwiardiirawan.blogspot.com/>
>