AjaxFormLoop not passing textField values after submit in T5.3.8

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

AjaxFormLoop not passing textField values after submit in T5.3.8

sheikh hossain
Hi,

We are upgrading our system from T5.1 to T5.3.8 ( not T5.4).

One of our pages is using AjaxFormLoop and it seems it's not passing the
textField value after clicking on 'submit' to the .java page file as it
always shows the default value and so the validation fails on the server
side.

I have tried with changing the code with Jumpstart 5.3.8 AjaxFormLoop
example but it still fails.

Here's the .tml section:
----
<div t:type="Zone" id="rateTableZone" -----
   - - - - -
<tr t:type="AjaxFormLoop" t:id="rateEntries" source="rateEntries"
encoder="rateEntryEncoder" value="rate">
                                        <td><t:textfield t:id="minValue"
id="minValue" class="minMaxClass" validate="none"
value="rate.minValue"/></td>
                                        <td><t:textField t:id="maxValue"
id="maxValue" class="minMaxClass" validate="none"
value="rate.maxValue"/></td>
    - - - - - - -

"rateEntries" is list of "RateTableEntry" which is a pojo containing
min/maxValue.

Here's what we have in the .java file:

- - - - - -
   @Persist
    @Property
    private List<RateTableEntry> rateEntries;

  @Persist(PersistenceConstants.FLASH)
    private RateTableEntry rate;

  - - - - - - -
  - - - - - - -

   RateTableEntry onAddRow() {
        BigDecimal minValue = BigDecimal.ZERO;
        RateTableEntry ret = new RateTableEntry(BigDecimal.ZERO, minValue,
BigDecimal.ZERO);

        rateEntries.add(ret);  // should it be removed. I tried with
removing it

        return ret;
    }


    public RateTableEntry getRate() {
        return rate;
    }


    public void setRate(final RateTableEntry entry) {
        rate = entry;
    }

   public ValueEncoder<RateTableEntry> getRateEntryEncoder() {
        return new ValueEncoder<RateTableEntry>() {

            @Override
            public String toClient(RateTableEntry aValue) {

                return String.valueOf(aValue.getId());
            }

            @Override
            public RateTableEntry   toValue(String aClientValue) {

                int index = Integer.parseInt(aClientValue);
                if (index >= 0) {
                    RateTableEntry r = RateTableEntry.get(index); //
RateTableEntry has  a static global list of entries

                    return r;
                }
                return rate;
            }
        };
    }

and the validation section :

         private boolean onValidateFromForm()  IOException {

       boolean ret = true;

        - - - - - - -
        - - - - - - -
            BigDecimal lastMax = null;
            for (RateTableEntry e : rateEntries) {

               BigDecimal minVal = e.getMinValue() == null ?
BigDecimal.ZERO : new BigDecimal(e.getMinValue());
                BigDecimal maxVal = e.getMaxValue() == null ? null : new
BigDecimal(e.getMaxValue());
        - - - - - - -

              if (minVal.compareTo(tempMax) >= 0) {

form.recordError(messages.format("validate.max-value-too-small", minVal,
tempMax));

                    ret = false;
                    continue;
                }

This validation is failing as the RateEntryTable always get the default
values after submitting for min/maxValue field which are 0 and 0.

  I wonder if anything is changed for AjaxForLoop for 5.3.8 as it used to
work for T5.1.

  I have tried with not using the @Persist annotation and using @Property
as it is done in the Jumpstart example but didn't work and it still shows
the default values.

  I wonder if I am missing something or I need to change/add something to
make it to work.

  I would appreciate any response or advice.

  Thank you.