A bit more on this. What seems to be going wrong that in my case the hidden 
form fields in the FormFragment's are submitted even when the fragments are 
hidden on initial render. When I show and hide them again, the hidden fields 
get a "disabled" attribute preventing them hidden from-fields from being 
submitted. It seems to me that this "disabled" attribute should also be 
provided on initial render if the fragment is hidden.

I now solved it by contributing some javascript to the ajax response disabling 
the hidden fields myself as shown in [1]. But I'm sure this is not how it is 
intended.

I'd love to feedback on this one. Thoughts?

Cheers,
Joost

[1] script in my event handler loading a Block containing the FormFragments and 
form elements.

ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
        public void run(JavaScriptSupport javascriptSupport) {                  
        
                if (!isShowCreditCardBlock()) {
                        
javascriptSupport.addScript("$$('.creditCardFormItems.t-invisible 
INPUT[type=hidden]')[0].disabled=true;");
                }

                if (!isShowManualInvoiceBlock()) {
                        
javascriptSupport.addScript("$$('.manualInvoiceBlock.t-invisible 
INPUT[type=hidden]')[0].disabled=true;");
               }
        }
});


On Jul 11, 2013, at 1:16 PM, Joost Schouten (ml) wrote:

> Hi,
> 
> I'm using a FormFragment triggered by two Radio's in a RadioGroup. This all
> works fine and validation works as expected. The hidden Fragment is ignored
> when the form is submitted. Except for one situation:
> 
> when I load the Form and containing FormFragment's in a Zone and use the
> visible attribute on the FormFragment to hide one of them due to a
> preselected Radio, the server will validate the fields in the Hidden
> FormFragment as well. If I select the Radio's back and forth it works as
> expected. When debugging I noticed the ProcessSubmission ComponentActions
> are executed where they are not when the formfragment is ignored as
> expected. Also the t:formdate is longer in my failing case as opposed to
> the scenario where it ignores my hidden fields. This leads me to believe
> there is some sort of javascript initialization call not being called in my
> failing case.
> 
> Has anyone seen this before? And clues on how to solve it? I'm on Tap 5.3.6
> 
> Thanks,
> Joost
> 
> some of my code:
> 
> @Component(id = "paymentTypeRadioGroup", parameters = {"value=paymentType",
> 
> "label=message:components.entities.EntitiesCreditCard.payByTypeLabel",
> 
> "validate=required"})
> 
> private RadioGroup paymentTypeRadioGroup;
> 
> 
>  @Mixins("TriggerFragment")
> 
> @Component(id = "payByCreditCardRadio", parameters = {
> "value=literal:CREDIT_CARD",
> 
> "label=message:components.entities.EntitiesCreditCard.payByCreditCard",
> 
> "fragment=creditCardBlock"})
> 
> private Radio payByCreditCardRadio;
> 
> 
> @Mixins("TriggerFragment")
> 
> @Component(id = "payByInvoiceRadio", parameters = {
> "value=literal:MANUAL_INVOICE",
> 
> "label=message:components.entities.EntitiesCreditCard.payByInvoice",
> 
> "fragment=manualInvoiceBlock"})
> 
> private Radio payByInvoiceRadio;
> 
> 
>  @Component(id = "creditCardBlock", parameters = {
> 
> "visible=prop:showCreditCardBlock",
> 
> "alwaysSubmit=literal:false"})
> 
> private FormFragment creditCardBlock;
> 
> 
> @Component(id = "manualInvoiceBlock", parameters = {
> 
> "visible=prop:showManualInvoiceBlock",
> 
> "alwaysSubmit=literal:false"})
> 
> private FormFragment manualInvoiceBlock;


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

Reply via email to