You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by fernandospr <fe...@gmail.com> on 2011/03/27 19:54:32 UTC

Page to select something and use the selection in another page

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Page to select something and use the selection in another page

Posted by Jeremy Thomerson <je...@wickettraining.com>.
window.opener?

http://www.w3schools.com/jsref/prop_win_opener.asp

On Sun, Mar 27, 2011 at 1:54 PM, fernandospr <fe...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

Re: Page to select something and use the selection in another page

Posted by James Carman <ja...@carmanconsulting.com>.
I'm sure one of the core devs can slap me upside the head here and say
"why didn't you do it this way, doofus", but again I had a deadline
and I just needed to get it working.  By no means do I know each and
every bit of the framework, so sometimes I come up with something that
could have been better done with a built-in framework feature or two.
In short, there very well may be a built-in solution to this problem.
If there is, I don't know about it.  I do know there has been some
work done recently to introduce an event facility into the framework.

On Mon, Apr 4, 2011 at 1:24 PM, fernandospr <fe...@gmail.com> wrote:
> I guess this is a common functionality.
> It's weird it was not included as part of the framework, right?
>
>
>
> On Mon, Apr 4, 2011 at 2:19 PM, James Carman [via Apache Wicket] <
> ml-node+3426105-1808787178-210116@n4.nabble.com> wrote:
>
>> That was a tricky part, getting the selected or created value back to
>> the original page.  Perhaps it would have been better implemented with
>> an event-driven approach, but I just went with what I could get
>> working quickly.  I'm sure I could come up with something more elegant
>> if I had the time to ponder. :)
>>
>>
>> On Mon, Apr 4, 2011 at 1:08 PM, fernandospr <[hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=0&by-user=t>>
>> wrote:
>>
>> > Thanks James. I think I got it.
>> >
>> > I think the key part is this:
>> > ((FooSelectionListener) page).fooSelected(foo);
>> >
>> > I guess "page" is the page that starts the loop and is waiting for a
>> > selection, that is why it implements fooSelected.
>> >
>> > I think I'll implement something similar but instead of using a foo
>> object
>> > for fooSelected, I'll use an id. Then redirect to the original "page" and
>> my
>> > fooSelected would load it from the database.
>> >
>> > Though, I'm not sure if the original "page" would be automatically
>> refreshed
>> > with the selection.
>> >
>> > I will have to try.
>> >
>> > Thanks.
>> >
>> > --
>> > View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426075.html<http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426075.html?by-user=t>
>>
>> > Sent from the Users forum mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=1&by-user=t>
>> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=2&by-user=t>
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=3&by-user=t>
>> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=4&by-user=t>
>>
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426105.html
>>  To unsubscribe from Page to select something and use the selection in
>> another page, click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3409591&code=ZmVybmFuZG9zcHJAZ21haWwuY29tfDM0MDk1OTF8LTIwODA5MTEwOTU=>.
>>
>>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426121.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Page to select something and use the selection in another page

Posted by fernandospr <fe...@gmail.com>.
I guess this is a common functionality.
It's weird it was not included as part of the framework, right?



On Mon, Apr 4, 2011 at 2:19 PM, James Carman [via Apache Wicket] <
ml-node+3426105-1808787178-210116@n4.nabble.com> wrote:

> That was a tricky part, getting the selected or created value back to
> the original page.  Perhaps it would have been better implemented with
> an event-driven approach, but I just went with what I could get
> working quickly.  I'm sure I could come up with something more elegant
> if I had the time to ponder. :)
>
>
> On Mon, Apr 4, 2011 at 1:08 PM, fernandospr <[hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=0&by-user=t>>
> wrote:
>
> > Thanks James. I think I got it.
> >
> > I think the key part is this:
> > ((FooSelectionListener) page).fooSelected(foo);
> >
> > I guess "page" is the page that starts the loop and is waiting for a
> > selection, that is why it implements fooSelected.
> >
> > I think I'll implement something similar but instead of using a foo
> object
> > for fooSelected, I'll use an id. Then redirect to the original "page" and
> my
> > fooSelected would load it from the database.
> >
> > Though, I'm not sure if the original "page" would be automatically
> refreshed
> > with the selection.
> >
> > I will have to try.
> >
> > Thanks.
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426075.html<http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426075.html?by-user=t>
>
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=1&by-user=t>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=2&by-user=t>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=3&by-user=t>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3426105&i=4&by-user=t>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426105.html
>  To unsubscribe from Page to select something and use the selection in
> another page, click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3409591&code=ZmVybmFuZG9zcHJAZ21haWwuY29tfDM0MDk1OTF8LTIwODA5MTEwOTU=>.
>
>


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426121.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Page to select something and use the selection in another page

Posted by James Carman <ja...@carmanconsulting.com>.
That was a tricky part, getting the selected or created value back to
the original page.  Perhaps it would have been better implemented with
an event-driven approach, but I just went with what I could get
working quickly.  I'm sure I could come up with something more elegant
if I had the time to ponder. :)


On Mon, Apr 4, 2011 at 1:08 PM, fernandospr <fe...@gmail.com> wrote:
> Thanks James. I think I got it.
>
> I think the key part is this:
> ((FooSelectionListener) page).fooSelected(foo);
>
> I guess "page" is the page that starts the loop and is waiting for a
> selection, that is why it implements fooSelected.
>
> I think I'll implement something similar but instead of using a foo object
> for fooSelected, I'll use an id. Then redirect to the original "page" and my
> fooSelected would load it from the database.
>
> Though, I'm not sure if the original "page" would be automatically refreshed
> with the selection.
>
> I will have to try.
>
> Thanks.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426075.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Page to select something and use the selection in another page

Posted by fernandospr <fe...@gmail.com>.
Thanks James. I think I got it.

I think the key part is this:
((FooSelectionListener) page).fooSelected(foo); 

I guess "page" is the page that starts the loop and is waiting for a
selection, that is why it implements fooSelected.

I think I'll implement something similar but instead of using a foo object
for fooSelected, I'll use an id. Then redirect to the original "page" and my
fooSelected would load it from the database.

Though, I'm not sure if the original "page" would be automatically refreshed
with the selection.

I will have to try.

Thanks.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3426075.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Page to select something and use the selection in another page

Posted by James Carman <ja...@carmanconsulting.com>.
On Sun, Mar 27, 2011 at 10:19 PM, fernandospr <fe...@gmail.com> wrote:
> @James thanks for the example code, but I'm not quite sure if I'm following.
> Please could you please put an example on which would be the first page,
> second page(selection)?

In our application, you would be on a page where you need to choose
(in a drop-down) a "foo".  If it's not there, then you'd click a link
to go through the loop page to create one.  Once it's created, you go
back to the original page and the new "foo" shows up and it's
selected.  In your case, you wouldn't be creating anything
(necessarily), the logic in my onCreate() method (minus the repository
stuff) would go in the handler code for the link to choose one of the
listed objects.

> What is fooRepostiory?

Think of a "repository" as a DAO.  The fooRepository is a reference to
a FooRepository object which represents the collection of all Foo
objects.  For more information on Repositories, Entities, etc., you
should check out the Domain-Driven Design book by Eric Evans:

http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215

> Is that the object being shared by both pages?

No.

> Where is onCreate method?

For my particular situation, it was on a form.

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


Re: Page to select something and use the selection in another page

Posted by fernandospr <fe...@gmail.com>.
@Clint it could be a modal or not. It does not matter. But, in the selection
page, I need to be able to list with a DataView and probably also filter the
entities using an input form.

@James thanks for the example code, but I'm not quite sure if I'm following.
Please could you please put an example on which would be the first page,
second page(selection)? What is fooRepostiory? Is that the object being
shared by both pages? Where is onCreate method?

Thanks.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-to-select-something-and-use-the-selection-in-another-page-tp3409591p3410589.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Page to select something and use the selection in another page

Posted by James Carman <ja...@carmanconsulting.com>.
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 <fe...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Page to select something and use the selection in another page

Posted by Clint Checketts <ch...@gmail.com>.
Could the second page be a modal window? Or do you require that it is
a separate browser window?

On Sunday, March 27, 2011, fernandospr <fe...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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