You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Konstantin Ignatyev <kg...@yahoo.com> on 2007/08/24 08:46:01 UTC

conditional markup change

I need to change presentation dynamically depending on
object status and I can do it with conditionally using
different panels like this:
if( getWSSession().getVisit().isSaved( v.getId() ) ){
            add( new VehicleUncompareControl(
"compareControl", new Model( v ), new Component[]{
ajaxTarget, VehicleItem.this}));
        } else{
            add( new VehicleCompareControl(
"compareControl", new Model( v ), new Component[]{
ajaxTarget, VehicleItem.this}));
        }

so far so good, BUT, when I click on the AjaxLink
inside of those panels they change status of the
component (vehicle), so I would like the item to
reflect the change - and THAT does not happens. It is
sort of understandable because component already has
been created...

But the question is: How can I do that in Wicket:
conditionally change markup and see effect of those 
changes for Ajax updates too?

Konstantin Ignatyev




PS: If this is a typical day on planet earth, humans will add fifteen million tons of carbon to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles of desert, eliminate between forty to one hundred species, erode seventy-one million tons of topsoil, add 2,700 tons of CFCs to the stratosphere, and increase their population by 263,000

Bowers, C.A.  The Culture of Denial:  Why the Environmental Movement Needs a Strategy for Reforming Universities and Public Schools.  New York:  State University of New York Press, 1997: (4) (5) (p.206)

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


Re: conditional markup change with AjaxEditableLabel

Posted by Eelco Hillenius <ee...@gmail.com>.
On 8/24/07, fhagen@s-und-n.de <fh...@s-und-n.de> wrote:
> Hi,
>
> i am using a subclass of AjaxEditableLabel.
> This one works fine so far but I have one Problem.
>
> If the value of the label is < 0 the markup should change.
> I tried it this way with no effect.
>
> public class MyAjaxEditableLabel extends AjaxEditableLabel{
>
> protected void onSubmit(AjaxRequestTarget target)
> {
>         [...]
>         if(position.getValue()[index] < 0)
>         {
>                 this.getLabel().add(new AttributeModifier("class", true,
> new Model("negativ")));
>         }
>         else{
>                 this.getLabel().add(new AttributeModifier("class", true,
> new Model("positiv")));
>         }
>
>         this.getLabel().setVisible(true);
>         this.getEditor().setVisible(false);
>         target.addComponent(MyAjaxEditableLabel.this);
> }
>
> }
>
> In my css - stylesheet the class "negativ" and "positv" are defined.
> So if the value of the label changes to < 0 nothing happens.
>
> Any suggestions?

If I recall correctly, attribute changes not rendered correctly with
ajax requests was an issue that was recently solved. Matej, was that
you who fixed it?

Eelco

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


conditional markup change with AjaxEditableLabel

Posted by fh...@s-und-n.de.
Hi, 

i am using a subclass of AjaxEditableLabel.
This one works fine so far but I have one Problem.

If the value of the label is < 0 the markup should change.
I tried it this way with no effect.

public class MyAjaxEditableLabel extends AjaxEditableLabel{

protected void onSubmit(AjaxRequestTarget target)
{
        [...]
        if(position.getValue()[index] < 0)
        {
                this.getLabel().add(new AttributeModifier("class", true, 
new Model("negativ")));
        }
        else{
                this.getLabel().add(new AttributeModifier("class", true, 
new Model("positiv")));
        }

        this.getLabel().setVisible(true);
        this.getEditor().setVisible(false);
        target.addComponent(MyAjaxEditableLabel.this);
}

}

In my css - stylesheet the class "negativ" and "positv" are defined.
So if the value of the label changes to < 0 nothing happens.

Any suggestions?

Fabian

Re: conditional markup change

Posted by Oleg Taranenko <ol...@web.de>.
Hello Konstantin,

Your code snippet is from panel constructor, is not it? So far it
executed only first time, by creating page!

Your need explicitly use in the link handler replaceWith() method. See
Component's javadoc.

Cheers,

Oleg.

Friday, August 24, 2007, 8:46:01 AM, you wrote:

> I need to change presentation dynamically depending on
> object status and I can do it with conditionally using
> different panels like this:
> if( getWSSession().getVisit().isSaved( v.getId() ) ){
>             add( new VehicleUncompareControl(
> "compareControl", new Model( v ), new Component[]{
> ajaxTarget, VehicleItem.this}));
>         } else{
>             add( new VehicleCompareControl(
> "compareControl", new Model( v ), new Component[]{
> ajaxTarget, VehicleItem.this}));
>         }

> so far so good, BUT, when I click on the AjaxLink
> inside of those panels they change status of the
> component (vehicle), so I would like the item to
> reflect the change - and THAT does not happens. It is
> sort of understandable because component already has
> been created...

> But the question is: How can I do that in Wicket:
> conditionally change markup and see effect of those 
> changes for Ajax updates too?

> Konstantin Ignatyev




> PS: If this is a typical day on planet earth, humans will add
> fifteen million tons of carbon to the atmosphere, destroy 115 square miles of
> tropical rainforest, create seventy-two miles of desert, eliminate
> between forty to one hundred species, erode seventy-one million tons of
> topsoil, add 2,700 tons of CFCs to the stratosphere, and increase their population by 263,000

> Bowers, C.A.  The Culture of Denial:  Why the Environmental
> Movement Needs a Strategy for Reforming Universities and Public Schools.  New
> York:  State University of New York Press, 1997: (4) (5) (p.206)

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



-- 
Best regards,
 Oleg                            mailto:otaranenko@key-software.com


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


Re: conditional markup change

Posted by Igor Vaynberg <ig...@gmail.com>.
there are a few ways to do this

one is to add both and override isvisible() on them to conditionally hide
one or the other

another way would be for that link to replace one with the other


-igor


On 8/23/07, Konstantin Ignatyev <kg...@yahoo.com> wrote:
>
> I need to change presentation dynamically depending on
> object status and I can do it with conditionally using
> different panels like this:
> if( getWSSession().getVisit().isSaved( v.getId() ) ){
>             add( new VehicleUncompareControl(
> "compareControl", new Model( v ), new Component[]{
> ajaxTarget, VehicleItem.this}));
>         } else{
>             add( new VehicleCompareControl(
> "compareControl", new Model( v ), new Component[]{
> ajaxTarget, VehicleItem.this}));
>         }
>
> so far so good, BUT, when I click on the AjaxLink
> inside of those panels they change status of the
> component (vehicle), so I would like the item to
> reflect the change - and THAT does not happens. It is
> sort of understandable because component already has
> been created...
>
> But the question is: How can I do that in Wicket:
> conditionally change markup and see effect of those
> changes for Ajax updates too?
>
> Konstantin Ignatyev
>
>
>
>
> PS: If this is a typical day on planet earth, humans will add fifteen
> million tons of carbon to the atmosphere, destroy 115 square miles of
> tropical rainforest, create seventy-two miles of desert, eliminate between
> forty to one hundred species, erode seventy-one million tons of topsoil, add
> 2,700 tons of CFCs to the stratosphere, and increase their population by
> 263,000
>
> Bowers, C.A.  The Culture of Denial:  Why the Environmental Movement Needs
> a Strategy for Reforming Universities and Public Schools.  New York:  State
> University of New York Press, 1997: (4) (5) (p.206)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>