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" <users@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/>
>

Reply via email to