FXValidationAjaxHandler - Javascript not added if component is set visible(false) in page constructor

View: New views
3 Messages — Rating Filter:   Alert me  

FXValidationAjaxHandler - Javascript not added if component is set visible(false) in page constructor

by christian.giambalvo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

ich have a component (textfield) with an FXValidationAjaxHandler. If i set this component in pageconstructor to visible(false) then the needed javascript code for validation is not contributed to pageheader. if set to visible(true) all is fine.
does anyone had the same problem and if so, is there a workaround available?

greets chris

snippet:
...
pComponent.add(new FXValidationAjaxHandler(pFXJavascriptEvent));
this.pComponent.setOutputMarkupPlaceholderTag(true);
this.pComponent.setOutputMarkupId(true)
this.pComponent.setVisible(false); // no javascript is added
//this.pComponent.setVisible(true); // javascript is added
form.add(this.pComponent);
...

Re: FXValidationAjaxHandler - Javascript not added if component is set visible(false) in page constructor

by jWeekend :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chris,

To better see what's going on, try the snippet below in the project attached to your latest post on this thread (Nabble is not showing me that post yet so I am replying here in case you need a solution quickly and this happens to be the real issue you are faced with)

     // ... mark t2 final and
     // add this to the end of your BasePage constuctor
     con.add(t2.setOutputMarkupId(true));
     add(new AjaxLink("toggleVisiblity"){
        @Override
        public void onClick(AjaxRequestTarget target) {
        t2.setVisible(!t2.isVisible());
        target.addComponent(t2);
        }
        });

Then, once you have clicked on the link, you can use FireBug in Firefox to verify that the "onblur" code you wanted is indeed in place.

Is that the effect you were after?

Regards - Cemal
jWeekend
OO & Java Technologies, Wicket Training and Development
http://jWeekend.com




christian.giambalvo wrote:
Hi all,

ich have a component (textfield) with an FXValidationAjaxHandler. If i set this component in pageconstructor to visible(false) then the needed javascript code for validation is not contributed to pageheader. if set to visible(true) all is fine.
does anyone had the same problem and if so, is there a workaround available?

greets chris

snippet:
...
pComponent.add(new FXValidationAjaxHandler(pFXJavascriptEvent));
this.pComponent.setOutputMarkupPlaceholderTag(true);
this.pComponent.setOutputMarkupId(true)
this.pComponent.setVisible(false); // no javascript is added
//this.pComponent.setVisible(true); // javascript is added
form.add(this.pComponent);
...

Re: FXValidationAjaxHandler - Javascript not added if component is set visible(false) in page constructor

by christian.giambalvo () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi, as long as the component is visible at pageconstructiontime the needed javascriptcode is inserted.
but as soon as i make it invisible in pageconstruction the javascriptcode don't get inserted.
the problem is, that i have 2 panels an depending on the selection of a dropdownchoice, the corresponding panel should be visible.
toogle visiblity isn't the problem if both are visible at beginning and setOutputMarkupId(true) and setOutputMarkupPlaceHolderTag(true) is set.


Chris,

To better see what's going on, try the snippet below in the project attached to your latest post on this thread (Nabble is not showing me that post yet so I am replying here in case you need a solution quickly and this happens to be the real issue you are faced with)

     // ... mark t2 final and
     // add this to the end of your BasePage constuctor
     con.add(t2.setOutputMarkupId(true));
     add(new AjaxLink("toggleVisiblity"){
        @Override
        public void onClick(AjaxRequestTarget target) {
        t2.setVisible(!t2.isVisible());
        target.addComponent(t2);
        }
        });

Then, once you have clicked on the link, you can use FireBug in Firefox to verify that the "onblur" code you wanted is indeed in place.

Is that the effect you were after?

Regards - Cemal
jWeekend
OO & Java Technologies, Wicket Training and Development
http://jWeekend.com




christian.giambalvo wrote:
Hi all,

ich have a component (textfield) with an FXValidationAjaxHandler. If i set this component in pageconstructor to visible(false) then the needed javascript code for validation is not contributed to pageheader. if set to visible(true) all is fine.
does anyone had the same problem and if so, is there a workaround available?

greets chris

snippet:
...
pComponent.add(new FXValidationAjaxHandler(pFXJavascriptEvent));
this.pComponent.setOutputMarkupPlaceholderTag(true);
this.pComponent.setOutputMarkupId(true)
this.pComponent.setVisible(false); // no javascript is added
//this.pComponent.setVisible(true); // javascript is added
form.add(this.pComponent);
...