You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2011/11/28 21:26:00 UTC

5.3 Bug AjaxFormLoop nested within Zone

When nesting an AjaxFormLoop within a Zone while giving the zone the
following parameters  update="fade" visible="false", on submit, the value
encoder doesn't seem to getting reached resulting in unsaved values. This
does seemed to work without issue in version 5.3.0 and prior. After doing
some more test, I have found if the zone is set to visible true, the values
are submitted without issue. I'm not sure if I'm doing something wrong, or a
new bug has been produced and needs to be filed. Any advise will be greatly
appreciated. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-Bug-AjaxFormLoop-nested-within-Zone-tp5029977p5029977.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: 5.3 Bug AjaxFormLoop nested within Zone

Posted by George Christman <gc...@cardaddy.com>.
I filed a JIRA bug and reverted back to version 5.3.0 until someone gets a
chance to look at it. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-Bug-AjaxFormLoop-nested-within-Zone-tp5029977p5032840.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: 5.3 Bug AjaxFormLoop nested within Zone

Posted by George Christman <gc...@cardaddy.com>.
I have found you can add a new row, but if you try modifying an existing row,
the changes don't seem to take effect. I'm posting my code below to be
reviewed. 

.tml
    <t:Zone t:id="formZone">
    <t:form t:id="admin" zone="formZone">
            Current State
            <t:ActionLink t:id="test" t:zone="testZone">test</t:ActionLink>
            <t:Zone t:id="testZone" id="testZone" visible="false">
                <div t:type="ajaxformloop" t:id="formValidations"
source="formValidations" value="formValidation" encoder="encoder">
                    <t:select t:id="currentState"
value="formValidation.currentState" model="stateModel" blankLabel="Select
Current State"/>
                    <t:removerowlink>remove</t:removerowlink>
                </div>  
            </t:Zone>
            <t:Submit value="Update"/>
    </t:form>
    </t:Zone>

.class    
    @Property
    private FormValidation formValidation;
    
    @Property
    @Persist
    private List<FormValidation> formValidations;
    
    @Inject
    private Session session;
    
    @Property
    @Persist
    private SelectModel stateModel;
    
    @Inject
    private SelectModelFactory selectModelFactory;
    
    @InjectComponent
    private Zone testZone, formZone;
    
    Object onActionFromTest() {
        return testZone.getBody();
    }
    
    void onPrepareForRender() {
        formValidations =
session.createCriteria(FormValidation.class).list();
        
        List<PrState> prStates =
session.createCriteria(PrState.class).list();
        stateModel = selectModelFactory.create(prStates, "Label");
    }
    
    @CommitAfter
    Object onSuccess() {
        for(FormValidation _formValidation : formValidations) {
            session.saveOrUpdate(_formValidation);
        }
        return formZone.getBody();
    }

    Object onAddRow() {
        formValidation = new FormValidation();
        formValidations.add(formValidation);
        return formValidation;
    }
    
    public ValueEncoder<FormValidation> getEncoder() {
        return new ValueEncoder<FormValidation>() {
            public String toClient(FormValidation formValidation) {
                return String.valueOf(formValidation.getTempId());
            }

            public FormValidation toValue(String clientValue) {
                Long key = new Long(clientValue);
                for (FormValidation holder : formValidations) {
                    if (holder.getTempId() == key) {
                        return holder;
                    }
                }
                return null;
            }
        };
    }
    
    @CommitAfter
    void onRemoveRow(FormValidation formValidation) {
        formValidations.remove(formValidation);
        session.delete(formValidation);
    }  

--
View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-Bug-AjaxFormLoop-nested-within-Zone-tp5029977p5032526.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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