Thiago,

Once more, thanks for your (extremely) quick answer :)
Indeed, It was a lot easier following your advice!

In case it can help somebody, here is the final template :

        <span id="${controlname}" class="monthdatafield">
            <label for="${controlName}-month"
class="date-label">${monthLabel}</label>
            <select id="${controlName}-month" name="${controlName}-month">
                <t:loop source="monthModel" value="month">
                    <t:if test="selectedMonth">
                        <option selected="yes">${month}</option>
                        <p:else>
                            <option>${month}</option>
                        </p:else>
                    </t:if>
                </t:loop>
            </select>
            <label for="${controlName}-year"
class="date-label">${yearLabel}</label>
            <select id="${controlName}-year" name="${controlName}-year">
                <t:loop source="yearModel" value="year">
                    <t:if test="selectedYear">
                        <option selected="yes">${year}</option>
                        <p:else>
                            <option>${year}</option>
                        </p:else>
                    </t:if>
                </t:loop>
            </select>
        </span>

And the corresponding code in MonthDateField.java :

@Override
protected void processSubmission(String elementName) {
        //Values retrieved
        String month = request.getParameter(getControlName()+"-month");
        String year = request.getParameter(getControlName()+"-year");

        SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy");

        String value = month+"-"+year;

        //The value is stored in tracker
         tracker.recordInput(this, value);
        .....
}

    public boolean isSelectedMonth(){
        String input = tracker.getInput(this);
        if ((input != null)&&(input.substring(0, 2).equals(month))) {
            return true;
        }
        return false;
    }

    public boolean isSelectedYear(){
        String input = tracker.getInput(this);
        if ((input != null)&&(input.substring(3).equals(year))) {
            return true;
        }
        return false;
    }

Have a nice day !

Thomas CUCCHIETTI.

2010/2/23 Thiago H. de Paula Figueiredo <thiag...@gmail.com>

> On Tue, 23 Feb 2010 12:31:38 -0300, Thomas Cucchietti <
> thomas.cucchie...@gmail.com> wrote:
>
>  Hi everybody,
>>
>
> Hi!
>
>
>  I'm facing a very annoying problem on one of my custom components.
>> Actually, it's a component (MonthDateField) made itself of  two select
>> components, like shown in its template :
>>
>
> Why don't you use two ordinary HTML select tags instead of relying in the
> Select component? It's easy and you won't have the problems you're having
> now. ;)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, software architect and developer, 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
>
>

Reply via email to