Hi everybody,

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 :

        <span id="${controlname}" class="monthdatafield">
            <label for="month" class="date-label">${monthLabel}</label>
            <t:select t:id="month" blankoption="never" value="month"
model="monthModel"/>
            <label for="year" class="date-label">${yearLabel}</label>
            <t:select t:id="year" blankoption="never" value="year"
model="yearModel"/>
        </span>

In the processSubmission method of my component java class, I want to
retrieve the values of those 2 select subcomponents.
I first wrote it like this :

        //Values retrieved
        String month = request.getParameter("month");
        String year = request.getParameter("year");

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

        String value = month+"-"+year;

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

So far, so good : it works perfectly when I make a test with one
monthdatefield component.

But I notice a strange behavior while using 2 MonthDateField components on
the same page. The reason is simple :
In the code above, i retrieve the values of the first MonthDateField only,
for which the select components ids are "month" and "year".
For the second one, the select subcomponents ids are "month_0" and "year_0".

How can I do to retrieve the values for each of the MonthDateField?

   - I can't use dynamic ids (like <select t:id="${elementName}-month" ...)
   - I tried to use the properties "month" and "year" of my MonthDateField
   class as they are needed for the value parameter of the select
   subcomponents, but they stay null....
   - I tried to inject my select subcomponents using @InjectComponent and to
   get the ids with the getClientId() method but same thing, they are always
   null

I begin to desperate to find a solution to this problem...

Does somebody have an idea ?

Thanks in advance,

Thomas CUCCHIETTI.

Reply via email to