In our application, we call these "loop" pages. Here's how we implemented it:
public abstract class LoopLink extends SubmitLink
{
public LoopLink(String id)
{
super(id);
setDefaultFormProcessing(false);
}
protected abstract Page getLoopPage();
@Override
public final void onSubmit()
{
setResponsePage(getLoopPage());
setRedirect(true);
}
}
public class LoopPage extends WebPage
{
protected final Breadcrumb breadcrumb;
public LoopPage()
{
this.breadcrumb = new Breadcrumb();
}
protected void redirectToDestination()
{
breadcrumb.redirectToDestination();
}
protected Page getDestinationPage()
{
return breadcrumb.getDestinationPage();
}
}
public class Breadcrumb implements Serializable
{
private final PageReference destination;
public Breadcrumb()
{
this.destination = PageReference.forRequestedPage();
}
public Link createCancelLink(String id)
{
return new CancelLink(id);
}
private class CancelLink extends Link
{
private static final long serialVersionUID = 1L;
public CancelLink(String id)
{
super(id);
}
public void onClick()
{
redirectToDestination();
}
}
public void redirectToDestination()
{
RequestCycle.get().setResponsePage(destination.getPage());
RequestCycle.get().setRedirect(true);
}
public Page getDestinationPage()
{
return destination.getPage();
}
}
So, to initiate going through the "loop", you just set up a LoopLink.
The LoopPage subclass will do something to select some information and
then go back to the page from whence the loop began:
protected void onCreate(Foo foo)
{
fooRepostiory.add(foo);
final Page page = getDestinationPage();
if (page instanceof FooSelectionListener)
{
((FooSelectionListener) page).fooSelected(foo);
}
info("New foo created successfully!");
redirectToDestination();
}
This seems to work for us just fine.
On Sun, Mar 27, 2011 at 1:54 PM, fernandospr <[email protected]> wrote:
> Hi,
>
>
> I need to build a page (1) where the user will have a form and one of the
> inputs will have a button that will open another page (2) where he/she will
> select something from a list, probably from a DataView, then accept and use
> the selected item in the form of page (1).
>
> Any ideas?
>
> Thanks in advance.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3409591.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]