You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Gregg Bolinger <gd...@gmail.com> on 2008/08/18 19:22:41 UTC

HTML Fragments

I apologize if this question has been addressed before however I didn't find
any thing doing a quick search.  What is the recommended practice for
handling HTML fragments from an AJAX response?  For example, if I were doing
something similar to jquery's load() or prototype's Updater() functions.
Since in Wicket it seems that each WebPage class represents a single HTML
page I'm having trouble wrapping my head around it.  In an action based
framework, like Stripes for example, I would simply have an event method
forward to my JSP that is being returned for the ajax request.  In Wicket,
being a component model, I'm just not clear on the procedure.

Take the Cheesr app from Wicket In Action, for example.  In Chapter 3 a
simple reusable cart component is made but it is plugged in and updated on a
normal request/response (non AJAX).  What would need to change for that
WebPage/HTML to be updated via an AJAX call?  Say if the Add link were
clicked.

Thanks.

Re: HTML Fragments

Posted by Martijn Dashorst <ma...@gmail.com>.
Chapter 5 of Wicket in Action covers this topic, to be more specific:
"Section 5.4.2 Using AjaxFallbackLink to respond to client actions",
and modifies the Cheesr store to use Ajax links to add items to the
shopping cart instead of using normal links.

Martijn

On Mon, Aug 18, 2008 at 7:22 PM, Gregg Bolinger
<gd...@gmail.com> wrote:
> I apologize if this question has been addressed before however I didn't find
> any thing doing a quick search.  What is the recommended practice for
> handling HTML fragments from an AJAX response?  For example, if I were doing
> something similar to jquery's load() or prototype's Updater() functions.
> Since in Wicket it seems that each WebPage class represents a single HTML
> page I'm having trouble wrapping my head around it.  In an action based
> framework, like Stripes for example, I would simply have an event method
> forward to my JSP that is being returned for the ajax request.  In Wicket,
> being a component model, I'm just not clear on the procedure.
>
> Take the Cheesr app from Wicket In Action, for example.  In Chapter 3 a
> simple reusable cart component is made but it is plugged in and updated on a
> normal request/response (non AJAX).  What would need to change for that
> WebPage/HTML to be updated via an AJAX call?  Say if the Add link were
> clicked.
>
> Thanks.
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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


Re: HTML Fragments

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
In an Ajax call you get a handle to the so-called ajax target.

The ajax target is used to ajax-update components ('to be updated via
an AJAX call').

So, roughly a non-ajax link is as follows:
page.add(new Link(xx));

An ajax link is as follows:
page.add(new AjaxLink(xx) {
   @Override
   onSubmit(Target target) {
       ... do your business logic here ...
      // Finally, indicate which components you need to update via ajax:
     target.addComponent(myAjaxUpdatePanelOrOtherComponent);
   }
});

For a simple example, see
http://www.wicket-library.com/wicket-examples/ajax/form.2

**
Martin

2008/8/18 Gregg Bolinger <gd...@gmail.com>:
> I apologize if this question has been addressed before however I didn't find
> any thing doing a quick search.  What is the recommended practice for
> handling HTML fragments from an AJAX response?  For example, if I were doing
> something similar to jquery's load() or prototype's Updater() functions.
> Since in Wicket it seems that each WebPage class represents a single HTML
> page I'm having trouble wrapping my head around it.  In an action based
> framework, like Stripes for example, I would simply have an event method
> forward to my JSP that is being returned for the ajax request.  In Wicket,
> being a component model, I'm just not clear on the procedure.
>
> Take the Cheesr app from Wicket In Action, for example.  In Chapter 3 a
> simple reusable cart component is made but it is plugged in and updated on a
> normal request/response (non AJAX).  What would need to change for that
> WebPage/HTML to be updated via an AJAX call?  Say if the Add link were
> clicked.
>
> Thanks.
>

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


Re: HTML Fragments

Posted by Gregg Bolinger <gd...@gmail.com>.
Thanks Scott. I think I get it now.

On Mon, Aug 18, 2008 at 12:33 PM, Scott Swank <sc...@gmail.com> wrote:

> You implement the onClick() method of a link such as the AjaxFallbackLink
>
>
> http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.html
>
> If the AjaxRequestTarget is null then the browser does not have
> JavaScript enabled.
>
> @Override
> public void onClick(AjaxRequestTarget target) {
>   if (target !=null)
>      target.addComponent(cart);
> }
>
> Scott
>
> On Mon, Aug 18, 2008 at 10:22 AM, Gregg Bolinger
> <gd...@gmail.com> wrote:
> > I apologize if this question has been addressed before however I didn't
> find
> > any thing doing a quick search.  What is the recommended practice for
> > handling HTML fragments from an AJAX response?  For example, if I were
> doing
> > something similar to jquery's load() or prototype's Updater() functions.
> > Since in Wicket it seems that each WebPage class represents a single HTML
> > page I'm having trouble wrapping my head around it.  In an action based
> > framework, like Stripes for example, I would simply have an event method
> > forward to my JSP that is being returned for the ajax request.  In
> Wicket,
> > being a component model, I'm just not clear on the procedure.
> >
> > Take the Cheesr app from Wicket In Action, for example.  In Chapter 3 a
> > simple reusable cart component is made but it is plugged in and updated
> on a
> > normal request/response (non AJAX).  What would need to change for that
> > WebPage/HTML to be updated via an AJAX call?  Say if the Add link were
> > clicked.
> >
> > Thanks.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: HTML Fragments

Posted by Scott Swank <sc...@gmail.com>.
You implement the onClick() method of a link such as the AjaxFallbackLink

http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.html

If the AjaxRequestTarget is null then the browser does not have
JavaScript enabled.

@Override
public void onClick(AjaxRequestTarget target) {
   if (target !=null)
      target.addComponent(cart);
}

Scott

On Mon, Aug 18, 2008 at 10:22 AM, Gregg Bolinger
<gd...@gmail.com> wrote:
> I apologize if this question has been addressed before however I didn't find
> any thing doing a quick search.  What is the recommended practice for
> handling HTML fragments from an AJAX response?  For example, if I were doing
> something similar to jquery's load() or prototype's Updater() functions.
> Since in Wicket it seems that each WebPage class represents a single HTML
> page I'm having trouble wrapping my head around it.  In an action based
> framework, like Stripes for example, I would simply have an event method
> forward to my JSP that is being returned for the ajax request.  In Wicket,
> being a component model, I'm just not clear on the procedure.
>
> Take the Cheesr app from Wicket In Action, for example.  In Chapter 3 a
> simple reusable cart component is made but it is plugged in and updated on a
> normal request/response (non AJAX).  What would need to change for that
> WebPage/HTML to be updated via an AJAX call?  Say if the Add link were
> clicked.
>
> Thanks.
>

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