You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ernesto Reinaldo Barreiro <re...@gmail.com> on 2012/12/12 16:23:00 UTC

AJAX updating of non "typical components"

Hi,

Several times I have encountered the situation where I want to "update" a
component via AJAX and this component does not have setOutputMarkupId(true)
or even the component generates no  visible markup.  All this component
needs is a way to repaint itself (either by adding some sub-components that
are re-paintable via AJAX or by generating some JavaScript that will update
component state at client side). So, what I want is being to do
target.add(myNotStandardComponent) and wicket to take care of its update...
Maybe by providing and  interface like

IAjaxUpdatable {

void update(AjaxRequestTarget target);

}

that marks the  component as being re-renderable via AJAX ... and modify
AjaxRequestTarget logic to take this into account.

I gave a look into the sources and the closest thing I have found is

interface ITargetRespondListener
{
/**
 * Invoked when AjaxRequestTarget is about the respond.
 *
 * @param target
 */
void onTargetRespond(AjaxRequestTarget target);
}

but these are added via target.registerRespondListener do not seem to be
the same.

Is the above a good idea? Or shall I simply use  ITargetRespondListener?

-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>

Re: AJAX updating of non "typical components"

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
So, essentially what I'm asking is to relax the condition

component.getOutputMarkupId() == true <==> AJAX updateable,

by introducing and alternative  IAjaxUpdateable  (marking a component as "I
know how to update myself via AJAX") for components with
component.getOutputMarkupId() == false or even setRenderBodyOnly(true).


On Wed, Dec 12, 2012 at 6:03 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> IHeaderContibutor won't work if component does not has
> setOutputMarkupId(true).... AjaxRequestHandler#add()
>
> public void add(Component... components)
> {
>  for (final Component component : components)
> {
> Args.notNull(component, "component");
>
> if (component.getOutputMarkupId() == false && !(component instanceof Page))
> {
>  throw new IllegalArgumentException(
> "cannot update component that does not have setOutputMarkupId property set
> to true. Component: " +
>  component.toString());
> }
> add(component, component.getMarkupId());
>  }
> }
>
> On Wed, Dec 12, 2012 at 4:59 PM, Martin Makundi <
> martin.makundi@koodaripalvelut.com> wrote:
>
>> IHeaderContributor?
>>
>> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
>> > Hi,
>> >
>> > Several times I have encountered the situation where I want to "update"
>> a
>> > component via AJAX and this component does not have
>> setOutputMarkupId(true)
>> > or even the component generates no  visible markup.  All this component
>> > needs is a way to repaint itself (either by adding some sub-components
>> that
>> > are re-paintable via AJAX or by generating some JavaScript that will
>> update
>> > component state at client side). So, what I want is being to do
>> > target.add(myNotStandardComponent) and wicket to take care of its
>> update...
>> > Maybe by providing and  interface like
>> >
>> > IAjaxUpdatable {
>> >
>> > void update(AjaxRequestTarget target);
>> >
>> > }
>> >
>> > that marks the  component as being re-renderable via AJAX ... and modify
>> > AjaxRequestTarget logic to take this into account.
>> >
>> > I gave a look into the sources and the closest thing I have found is
>> >
>> > interface ITargetRespondListener
>> > {
>> > /**
>> >  * Invoked when AjaxRequestTarget is about the respond.
>> >  *
>> >  * @param target
>> >  */
>> > void onTargetRespond(AjaxRequestTarget target);
>> > }
>> >
>> > but these are added via target.registerRespondListener do not seem to be
>> > the same.
>> >
>> > Is the above a good idea? Or shall I simply use  ITargetRespondListener?
>> >
>> > --
>> > Regards - Ernesto Reinaldo Barreiro
>> > Antilia Soft
>> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>
>


-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>

Re: AJAX updating of non "typical components"

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
1. Please also implement this expert/newuser mode as boolean closeonhover
setting inside notificationspanel:

    public void onTargetRespond(AjaxRequestTarget target) {
      if(isExpertMode()) {
        renderErrorNotifications(target, getString("timeManagement.error"),
new NotificationSettings()
        .setExpires(false).setUseHoverIntent(false),
NotificationsPanel.CloseOnHoverFunction.instance,
NotificationsPanel.CloseAllBeforeOpenFunction.instance);
      } else {
        renderErrorNotifications(target, getString("timeManagement.error"),
new NotificationSettings()
        .setExpires(false).setUseHoverIntent(false),
NotificationsPanel.CloseAllBeforeOpenFunction.instance);
      }
    }

2. Looking at "timeManagement.error", does it work with different level
errors/warnings/info?

2012/12/12 Martin Makundi <ma...@koodaripalvelut.com>

> Why not have outputmarkupid=true?
>
> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> > IHeaderContibutor won't work if component does not has
> > setOutputMarkupId(true).... AjaxRequestHandler#add()
> >
> > public void add(Component... components)
> > {
> > for (final Component component : components)
> > {
> > Args.notNull(component, "component");
> >
> > if (component.getOutputMarkupId() == false && !(component instanceof
> Page))
> > {
> > throw new IllegalArgumentException(
> > "cannot update component that does not have setOutputMarkupId property
> set
> > to true. Component: " +
> > component.toString());
> > }
> > add(component, component.getMarkupId());
> > }
> > }
> >
> > On Wed, Dec 12, 2012 at 4:59 PM, Martin Makundi <
> > martin.makundi@koodaripalvelut.com> wrote:
> >
> >> IHeaderContributor?
> >>
> >> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> >> > Hi,
> >> >
> >> > Several times I have encountered the situation where I want to
> "update" a
> >> > component via AJAX and this component does not have
> >> setOutputMarkupId(true)
> >> > or even the component generates no  visible markup.  All this
> component
> >> > needs is a way to repaint itself (either by adding some sub-components
> >> that
> >> > are re-paintable via AJAX or by generating some JavaScript that will
> >> update
> >> > component state at client side). So, what I want is being to do
> >> > target.add(myNotStandardComponent) and wicket to take care of its
> >> update...
> >> > Maybe by providing and  interface like
> >> >
> >> > IAjaxUpdatable {
> >> >
> >> > void update(AjaxRequestTarget target);
> >> >
> >> > }
> >> >
> >> > that marks the  component as being re-renderable via AJAX ... and
> modify
> >> > AjaxRequestTarget logic to take this into account.
> >> >
> >> > I gave a look into the sources and the closest thing I have found is
> >> >
> >> > interface ITargetRespondListener
> >> > {
> >> > /**
> >> >  * Invoked when AjaxRequestTarget is about the respond.
> >> >  *
> >> >  * @param target
> >> >  */
> >> > void onTargetRespond(AjaxRequestTarget target);
> >> > }
> >> >
> >> > but these are added via target.registerRespondListener do not seem to
> be
> >> > the same.
> >> >
> >> > Is the above a good idea? Or shall I simply use
>  ITargetRespondListener?
> >> >
> >> > --
> >> > Regards - Ernesto Reinaldo Barreiro
> >> > Antilia Soft
> >> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> > Antilia Soft
> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>

Re: AJAX updating of non "typical components"

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Maybe add a dummy component inside the panel that is refreshed instead
and piggybacks your js or smth.

2012/12/13 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> Hi,
>
> On Wed, Dec 12, 2012 at 8:29 PM, Martin Makundi <
> martin.makundi@koodaripalvelut.com> wrote:
>
>> Why not have outputmarkupid=true?
>>
>>
> In this particular use case doing that would mean that a IFeedback panel,
> based on (
> http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/),
> will be reconstructed any time there are errors on page (all JS, and
> dependencies will be streamed back to the server as PART of ART) while the
> only thing that is need is pass back some JavaScript (e.g. appended to ART)
> that adds some notifications at client side widget.
>
>
>
>> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
>> > IHeaderContibutor won't work if component does not has
>> > setOutputMarkupId(true).... AjaxRequestHandler#add()
>> >
>> > public void add(Component... components)
>> > {
>> > for (final Component component : components)
>> > {
>> > Args.notNull(component, "component");
>> >
>> > if (component.getOutputMarkupId() == false && !(component instanceof
>> Page))
>> > {
>> > throw new IllegalArgumentException(
>> > "cannot update component that does not have setOutputMarkupId property
>> set
>> > to true. Component: " +
>> > component.toString());
>> > }
>> > add(component, component.getMarkupId());
>> > }
>> > }
>> >
>> > On Wed, Dec 12, 2012 at 4:59 PM, Martin Makundi <
>> > martin.makundi@koodaripalvelut.com> wrote:
>> >
>> >> IHeaderContributor?
>> >>
>> >> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
>> >> > Hi,
>> >> >
>> >> > Several times I have encountered the situation where I want to
>> "update" a
>> >> > component via AJAX and this component does not have
>> >> setOutputMarkupId(true)
>> >> > or even the component generates no  visible markup.  All this
>> component
>> >> > needs is a way to repaint itself (either by adding some sub-components
>> >> that
>> >> > are re-paintable via AJAX or by generating some JavaScript that will
>> >> update
>> >> > component state at client side). So, what I want is being to do
>> >> > target.add(myNotStandardComponent) and wicket to take care of its
>> >> update...
>> >> > Maybe by providing and  interface like
>> >> >
>> >> > IAjaxUpdatable {
>> >> >
>> >> > void update(AjaxRequestTarget target);
>> >> >
>> >> > }
>> >> >
>> >> > that marks the  component as being re-renderable via AJAX ... and
>> modify
>> >> > AjaxRequestTarget logic to take this into account.
>> >> >
>> >> > I gave a look into the sources and the closest thing I have found is
>> >> >
>> >> > interface ITargetRespondListener
>> >> > {
>> >> > /**
>> >> >  * Invoked when AjaxRequestTarget is about the respond.
>> >> >  *
>> >> >  * @param target
>> >> >  */
>> >> > void onTargetRespond(AjaxRequestTarget target);
>> >> > }
>> >> >
>> >> > but these are added via target.registerRespondListener do not seem to
>> be
>> >> > the same.
>> >> >
>> >> > Is the above a good idea? Or shall I simply use
>>  ITargetRespondListener?
>> >> >
>> >> > --
>> >> > Regards - Ernesto Reinaldo Barreiro
>> >> > Antilia Soft
>> >> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > Regards - Ernesto Reinaldo Barreiro
>> > Antilia Soft
>> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ <http://antiliasoft.com/antilia>

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


Re: AJAX updating of non "typical components"

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,

On Wed, Dec 12, 2012 at 8:29 PM, Martin Makundi <
martin.makundi@koodaripalvelut.com> wrote:

> Why not have outputmarkupid=true?
>
>
In this particular use case doing that would mean that a IFeedback panel,
based on (
http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/),
will be reconstructed any time there are errors on page (all JS, and
dependencies will be streamed back to the server as PART of ART) while the
only thing that is need is pass back some JavaScript (e.g. appended to ART)
that adds some notifications at client side widget.



> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> > IHeaderContibutor won't work if component does not has
> > setOutputMarkupId(true).... AjaxRequestHandler#add()
> >
> > public void add(Component... components)
> > {
> > for (final Component component : components)
> > {
> > Args.notNull(component, "component");
> >
> > if (component.getOutputMarkupId() == false && !(component instanceof
> Page))
> > {
> > throw new IllegalArgumentException(
> > "cannot update component that does not have setOutputMarkupId property
> set
> > to true. Component: " +
> > component.toString());
> > }
> > add(component, component.getMarkupId());
> > }
> > }
> >
> > On Wed, Dec 12, 2012 at 4:59 PM, Martin Makundi <
> > martin.makundi@koodaripalvelut.com> wrote:
> >
> >> IHeaderContributor?
> >>
> >> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> >> > Hi,
> >> >
> >> > Several times I have encountered the situation where I want to
> "update" a
> >> > component via AJAX and this component does not have
> >> setOutputMarkupId(true)
> >> > or even the component generates no  visible markup.  All this
> component
> >> > needs is a way to repaint itself (either by adding some sub-components
> >> that
> >> > are re-paintable via AJAX or by generating some JavaScript that will
> >> update
> >> > component state at client side). So, what I want is being to do
> >> > target.add(myNotStandardComponent) and wicket to take care of its
> >> update...
> >> > Maybe by providing and  interface like
> >> >
> >> > IAjaxUpdatable {
> >> >
> >> > void update(AjaxRequestTarget target);
> >> >
> >> > }
> >> >
> >> > that marks the  component as being re-renderable via AJAX ... and
> modify
> >> > AjaxRequestTarget logic to take this into account.
> >> >
> >> > I gave a look into the sources and the closest thing I have found is
> >> >
> >> > interface ITargetRespondListener
> >> > {
> >> > /**
> >> >  * Invoked when AjaxRequestTarget is about the respond.
> >> >  *
> >> >  * @param target
> >> >  */
> >> > void onTargetRespond(AjaxRequestTarget target);
> >> > }
> >> >
> >> > but these are added via target.registerRespondListener do not seem to
> be
> >> > the same.
> >> >
> >> > Is the above a good idea? Or shall I simply use
>  ITargetRespondListener?
> >> >
> >> > --
> >> > Regards - Ernesto Reinaldo Barreiro
> >> > Antilia Soft
> >> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> > Antilia Soft
> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>

Re: AJAX updating of non "typical components"

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Why not have outputmarkupid=true?

2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> IHeaderContibutor won't work if component does not has
> setOutputMarkupId(true).... AjaxRequestHandler#add()
>
> public void add(Component... components)
> {
> for (final Component component : components)
> {
> Args.notNull(component, "component");
>
> if (component.getOutputMarkupId() == false && !(component instanceof Page))
> {
> throw new IllegalArgumentException(
> "cannot update component that does not have setOutputMarkupId property set
> to true. Component: " +
> component.toString());
> }
> add(component, component.getMarkupId());
> }
> }
>
> On Wed, Dec 12, 2012 at 4:59 PM, Martin Makundi <
> martin.makundi@koodaripalvelut.com> wrote:
>
>> IHeaderContributor?
>>
>> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
>> > Hi,
>> >
>> > Several times I have encountered the situation where I want to "update" a
>> > component via AJAX and this component does not have
>> setOutputMarkupId(true)
>> > or even the component generates no  visible markup.  All this component
>> > needs is a way to repaint itself (either by adding some sub-components
>> that
>> > are re-paintable via AJAX or by generating some JavaScript that will
>> update
>> > component state at client side). So, what I want is being to do
>> > target.add(myNotStandardComponent) and wicket to take care of its
>> update...
>> > Maybe by providing and  interface like
>> >
>> > IAjaxUpdatable {
>> >
>> > void update(AjaxRequestTarget target);
>> >
>> > }
>> >
>> > that marks the  component as being re-renderable via AJAX ... and modify
>> > AjaxRequestTarget logic to take this into account.
>> >
>> > I gave a look into the sources and the closest thing I have found is
>> >
>> > interface ITargetRespondListener
>> > {
>> > /**
>> >  * Invoked when AjaxRequestTarget is about the respond.
>> >  *
>> >  * @param target
>> >  */
>> > void onTargetRespond(AjaxRequestTarget target);
>> > }
>> >
>> > but these are added via target.registerRespondListener do not seem to be
>> > the same.
>> >
>> > Is the above a good idea? Or shall I simply use  ITargetRespondListener?
>> >
>> > --
>> > Regards - Ernesto Reinaldo Barreiro
>> > Antilia Soft
>> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ <http://antiliasoft.com/antilia>

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


Re: AJAX updating of non "typical components"

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
IHeaderContibutor won't work if component does not has
setOutputMarkupId(true).... AjaxRequestHandler#add()

public void add(Component... components)
{
for (final Component component : components)
{
Args.notNull(component, "component");

if (component.getOutputMarkupId() == false && !(component instanceof Page))
{
throw new IllegalArgumentException(
"cannot update component that does not have setOutputMarkupId property set
to true. Component: " +
component.toString());
}
add(component, component.getMarkupId());
}
}

On Wed, Dec 12, 2012 at 4:59 PM, Martin Makundi <
martin.makundi@koodaripalvelut.com> wrote:

> IHeaderContributor?
>
> 2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> > Hi,
> >
> > Several times I have encountered the situation where I want to "update" a
> > component via AJAX and this component does not have
> setOutputMarkupId(true)
> > or even the component generates no  visible markup.  All this component
> > needs is a way to repaint itself (either by adding some sub-components
> that
> > are re-paintable via AJAX or by generating some JavaScript that will
> update
> > component state at client side). So, what I want is being to do
> > target.add(myNotStandardComponent) and wicket to take care of its
> update...
> > Maybe by providing and  interface like
> >
> > IAjaxUpdatable {
> >
> > void update(AjaxRequestTarget target);
> >
> > }
> >
> > that marks the  component as being re-renderable via AJAX ... and modify
> > AjaxRequestTarget logic to take this into account.
> >
> > I gave a look into the sources and the closest thing I have found is
> >
> > interface ITargetRespondListener
> > {
> > /**
> >  * Invoked when AjaxRequestTarget is about the respond.
> >  *
> >  * @param target
> >  */
> > void onTargetRespond(AjaxRequestTarget target);
> > }
> >
> > but these are added via target.registerRespondListener do not seem to be
> > the same.
> >
> > Is the above a good idea? Or shall I simply use  ITargetRespondListener?
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> > Antilia Soft
> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>

Re: AJAX updating of non "typical components"

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
IHeaderContributor?

2012/12/12 Ernesto Reinaldo Barreiro <re...@gmail.com>:
> Hi,
>
> Several times I have encountered the situation where I want to "update" a
> component via AJAX and this component does not have setOutputMarkupId(true)
> or even the component generates no  visible markup.  All this component
> needs is a way to repaint itself (either by adding some sub-components that
> are re-paintable via AJAX or by generating some JavaScript that will update
> component state at client side). So, what I want is being to do
> target.add(myNotStandardComponent) and wicket to take care of its update...
> Maybe by providing and  interface like
>
> IAjaxUpdatable {
>
> void update(AjaxRequestTarget target);
>
> }
>
> that marks the  component as being re-renderable via AJAX ... and modify
> AjaxRequestTarget logic to take this into account.
>
> I gave a look into the sources and the closest thing I have found is
>
> interface ITargetRespondListener
> {
> /**
>  * Invoked when AjaxRequestTarget is about the respond.
>  *
>  * @param target
>  */
> void onTargetRespond(AjaxRequestTarget target);
> }
>
> but these are added via target.registerRespondListener do not seem to be
> the same.
>
> Is the above a good idea? Or shall I simply use  ITargetRespondListener?
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ <http://antiliasoft.com/antilia>

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