You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Corbin, James" <jc...@iqnavigator.com> on 2010/02/26 20:04:27 UTC

Conditionally Render Different Fragments (via Radio Choice Selection)?

I have radio group (RadioChoice) with two options that conditionally renders one of two fragments.

The two fragments are pre-created and then attach onchange ajax behavior to the RadioChoice component that toggles the visibility of the fragments depending upon the selection made for the RadioChoice component.

When I toggle the radio choice to the second option, my fragment isn't being rendered when I setVisible(true).

In my ajax update method, I toggle the visibility for the fragments and then
target.addComponent(fragment1);
target.addComponent(fragment2);

I tried target.addComponent(form), where form is the container for the RadioChoice and Fragments.

I made sure that I specify setOutputMarkupPlaceholderTag(true) on both fragments at creation time.

I'm not sure what is going on here?

J.D.

Re: Conditionally Render Different Fragments (via Radio Choice Selection)?

Posted by Riyad Kalla <rk...@gmail.com>.
J.D.,

What did your HTML look like for each of these conditional "fragments" and
how were they represented in your code before you fixed it?

Curious what it looked like before/after for my own know-how.

-R

On Fri, Feb 26, 2010 at 12:26 PM, Corbin, James <jc...@iqnavigator.com>wrote:

> I looked at the ajax debug output and noticed there was no reference to one
> of the fragments.
>
> With only one div for the fragment, what I needed to do was conditionally
> add and remove the fragment components depending upon the selection of the
> RadioChoice and re-add the form via target.addComponent(...)
>
> Another option I considered and went with was just to add another div for
> the second fragment adding both to the container form and conditionally
> rendering them by setting their visibility appropriately.
>
> J.D.
>
> -----Original Message-----
> From: Riyad Kalla [mailto:rkalla@gmail.com]
> Sent: Friday, February 26, 2010 12:16 PM
> To: users@wicket.apache.org
> Subject: Re: Conditionally Render Different Fragments (via Radio Choice
> Selection)?
>
> JD,
>
> If you flip the initial visible fragment to the 2nd one, does the inverse
> condition apply? (frag2 is visible and frag1 isn't visible?)
>
> If you check the source of the generated HTML, you are seeing the generated
> placeholder tag for the 2nd fragment so it can be made visible right?
>
> -R
>
> On Fri, Feb 26, 2010 at 12:04 PM, Corbin, James <jcorbin@iqnavigator.com
> >wrote:
>
> > I have radio group (RadioChoice) with two options that conditionally
> > renders one of two fragments.
> >
> > The two fragments are pre-created and then attach onchange ajax behavior
> to
> > the RadioChoice component that toggles the visibility of the fragments
> > depending upon the selection made for the RadioChoice component.
> >
> > When I toggle the radio choice to the second option, my fragment isn't
> > being rendered when I setVisible(true).
> >
> > In my ajax update method, I toggle the visibility for the fragments and
> > then
> > target.addComponent(fragment1);
> > target.addComponent(fragment2);
> >
> > I tried target.addComponent(form), where form is the container for the
> > RadioChoice and Fragments.
> >
> > I made sure that I specify setOutputMarkupPlaceholderTag(true) on both
> > fragments at creation time.
> >
> > I'm not sure what is going on here?
> >
> > J.D.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Conditionally Render Different Fragments (via Radio Choice Selection)?

Posted by "Corbin, James" <jc...@iqnavigator.com>.
I looked at the ajax debug output and noticed there was no reference to one of the fragments.

With only one div for the fragment, what I needed to do was conditionally add and remove the fragment components depending upon the selection of the RadioChoice and re-add the form via target.addComponent(...)

Another option I considered and went with was just to add another div for the second fragment adding both to the container form and conditionally rendering them by setting their visibility appropriately.

J.D.

-----Original Message-----
From: Riyad Kalla [mailto:rkalla@gmail.com] 
Sent: Friday, February 26, 2010 12:16 PM
To: users@wicket.apache.org
Subject: Re: Conditionally Render Different Fragments (via Radio Choice Selection)?

JD,

If you flip the initial visible fragment to the 2nd one, does the inverse
condition apply? (frag2 is visible and frag1 isn't visible?)

If you check the source of the generated HTML, you are seeing the generated
placeholder tag for the 2nd fragment so it can be made visible right?

-R

On Fri, Feb 26, 2010 at 12:04 PM, Corbin, James <jc...@iqnavigator.com>wrote:

> I have radio group (RadioChoice) with two options that conditionally
> renders one of two fragments.
>
> The two fragments are pre-created and then attach onchange ajax behavior to
> the RadioChoice component that toggles the visibility of the fragments
> depending upon the selection made for the RadioChoice component.
>
> When I toggle the radio choice to the second option, my fragment isn't
> being rendered when I setVisible(true).
>
> In my ajax update method, I toggle the visibility for the fragments and
> then
> target.addComponent(fragment1);
> target.addComponent(fragment2);
>
> I tried target.addComponent(form), where form is the container for the
> RadioChoice and Fragments.
>
> I made sure that I specify setOutputMarkupPlaceholderTag(true) on both
> fragments at creation time.
>
> I'm not sure what is going on here?
>
> J.D.
>


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


Re: Conditionally Render Different Fragments (via Radio Choice Selection)?

Posted by Riyad Kalla <rk...@gmail.com>.
JD,

If you flip the initial visible fragment to the 2nd one, does the inverse
condition apply? (frag2 is visible and frag1 isn't visible?)

If you check the source of the generated HTML, you are seeing the generated
placeholder tag for the 2nd fragment so it can be made visible right?

-R

On Fri, Feb 26, 2010 at 12:04 PM, Corbin, James <jc...@iqnavigator.com>wrote:

> I have radio group (RadioChoice) with two options that conditionally
> renders one of two fragments.
>
> The two fragments are pre-created and then attach onchange ajax behavior to
> the RadioChoice component that toggles the visibility of the fragments
> depending upon the selection made for the RadioChoice component.
>
> When I toggle the radio choice to the second option, my fragment isn't
> being rendered when I setVisible(true).
>
> In my ajax update method, I toggle the visibility for the fragments and
> then
> target.addComponent(fragment1);
> target.addComponent(fragment2);
>
> I tried target.addComponent(form), where form is the container for the
> RadioChoice and Fragments.
>
> I made sure that I specify setOutputMarkupPlaceholderTag(true) on both
> fragments at creation time.
>
> I'm not sure what is going on here?
>
> J.D.
>