You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dd du <da...@gmail.com> on 2007/11/09 05:22:33 UTC

Can wicket handle events generated from javascript created?

Hi, all,
I am new to wicket, I have a question about calling javascript from wicket,
suppose I create a page from wicket, from this page I click a button, which
wicket will call a javascript function, this function will create a dialog
window with fancy GUI controls, from these controls, if I click one of them,
an event handler from that javascript file will be called, inside this
handler, I need to call back to a wicket java method to handle business
logic, now how can I do that? I know if wicket creates all the GUI controls,
wicket can handle the events easily, but I want javascript to create them
since it deals with fancy style sheets.

Is there a way wicket can handle events generated from javascript created
buttons? or a way calling back to wicket java code from javascript code?

Thanks

David

Re: Can wicket handle events generated from javascript created?

Posted by Igor Vaynberg <ig...@gmail.com>.
like i said, look at how Link component generates a url back to itself
which invokes it's onlinkclicked() listener

-igor


On Nov 9, 2007 2:21 PM, dd du <da...@gmail.com> wrote:
> Igor, Thanks again for your response, do you have a way to invoke a
> listener? I like to click a button from javascript, then somehow a java
> method in a page class can be called, this page class originally calls the
> javascript, which creates all the GUI control and buttons.
>
> David
>
>
>
> On 11/9/07, Igor Vaynberg <ig...@gmail.com> wrote:
> >
> > what do you want to do when the button is clicked?  invoke a listener
> > or simply go to a page?
> >
> > if go to a page just do:
> >
> > String pageurl=urlfor(MyPage.class); and pass that string to your js
> > which can later do window.location=url;
> >
> > -igor
> >
> >
> > On Nov 9, 2007 7:37 AM, dd du <da...@gmail.com> wrote:
> > > Hi, igor, thanks for your response, I am not sure I understand what you
> > > mean, can you make it a little bit more specific or direct me to example
> > or
> > > where to start to look at it? I am thinking to pass an url to
> > javascript,
> > > when a button created from javascript is clicked, then direct it to the
> > url,
> > > which points to a page generated in wicket, but this is not a short-cut
> > way,
> > > also I am trying to download wicket source code to see how AjaxLink
> > class is
> > > implemented since when an ajax link is clicked, the
> > > onClick(AjaxRequestTarget) method is called, maybe I can borrow some
> > ideas
> > > there, but the wicket site has no source code to download, the release
> > zip
> > > file does not contain the source code for wicket, only source code for
> > the
> > > examples, any way to get the wicket open source code?
> > >
> > > Thanks
> > >
> > >
> > >
> > > On 11/9/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > > >
> > > > there is no magic here. look at how Link#getURL() works - it generates
> > > > a url that invokes onLinkClicked on that Link component. you can use
> > > > much the same mechanism and pass that url to your javascript.
> > > >
> > > > -igor
> > > >
> > > >
> > > > On Nov 8, 2007 8:22 PM, dd du <da...@gmail.com> wrote:
> > > > > Hi, all,
> > > > > I am new to wicket, I have a question about calling javascript from
> > > > wicket,
> > > > > suppose I create a page from wicket, from this page I click a
> > button,
> > > > which
> > > > > wicket will call a javascript function, this function will create a
> > > > dialog
> > > > > window with fancy GUI controls, from these controls, if I click one
> > of
> > > > them,
> > > > > an event handler from that javascript file will be called, inside
> > this
> > > > > handler, I need to call back to a wicket java method to handle
> > business
> > > > > logic, now how can I do that? I know if wicket creates all the GUI
> > > > controls,
> > > > > wicket can handle the events easily, but I want javascript to create
> > > > them
> > > > > since it deals with fancy style sheets.
> > > > >
> > > > > Is there a way wicket can handle events generated from javascript
> > > > created
> > > > > buttons? or a way calling back to wicket java code from javascript
> > code?
> > > > >
> > > > > Thanks
> > > > >
> > > > > David
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > 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
> >
> >
>

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


Re: Can wicket handle events generated from javascript created?

Posted by dd du <da...@gmail.com>.
Igor, Thanks again for your response, do you have a way to invoke a
listener? I like to click a button from javascript, then somehow a java
method in a page class can be called, this page class originally calls the
javascript, which creates all the GUI control and buttons.

David


On 11/9/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> what do you want to do when the button is clicked?  invoke a listener
> or simply go to a page?
>
> if go to a page just do:
>
> String pageurl=urlfor(MyPage.class); and pass that string to your js
> which can later do window.location=url;
>
> -igor
>
>
> On Nov 9, 2007 7:37 AM, dd du <da...@gmail.com> wrote:
> > Hi, igor, thanks for your response, I am not sure I understand what you
> > mean, can you make it a little bit more specific or direct me to example
> or
> > where to start to look at it? I am thinking to pass an url to
> javascript,
> > when a button created from javascript is clicked, then direct it to the
> url,
> > which points to a page generated in wicket, but this is not a short-cut
> way,
> > also I am trying to download wicket source code to see how AjaxLink
> class is
> > implemented since when an ajax link is clicked, the
> > onClick(AjaxRequestTarget) method is called, maybe I can borrow some
> ideas
> > there, but the wicket site has no source code to download, the release
> zip
> > file does not contain the source code for wicket, only source code for
> the
> > examples, any way to get the wicket open source code?
> >
> > Thanks
> >
> >
> >
> > On 11/9/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > >
> > > there is no magic here. look at how Link#getURL() works - it generates
> > > a url that invokes onLinkClicked on that Link component. you can use
> > > much the same mechanism and pass that url to your javascript.
> > >
> > > -igor
> > >
> > >
> > > On Nov 8, 2007 8:22 PM, dd du <da...@gmail.com> wrote:
> > > > Hi, all,
> > > > I am new to wicket, I have a question about calling javascript from
> > > wicket,
> > > > suppose I create a page from wicket, from this page I click a
> button,
> > > which
> > > > wicket will call a javascript function, this function will create a
> > > dialog
> > > > window with fancy GUI controls, from these controls, if I click one
> of
> > > them,
> > > > an event handler from that javascript file will be called, inside
> this
> > > > handler, I need to call back to a wicket java method to handle
> business
> > > > logic, now how can I do that? I know if wicket creates all the GUI
> > > controls,
> > > > wicket can handle the events easily, but I want javascript to create
> > > them
> > > > since it deals with fancy style sheets.
> > > >
> > > > Is there a way wicket can handle events generated from javascript
> > > created
> > > > buttons? or a way calling back to wicket java code from javascript
> code?
> > > >
> > > > Thanks
> > > >
> > > > David
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > 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: Can wicket handle events generated from javascript created?

Posted by Igor Vaynberg <ig...@gmail.com>.
what do you want to do when the button is clicked?  invoke a listener
or simply go to a page?

if go to a page just do:

String pageurl=urlfor(MyPage.class); and pass that string to your js
which can later do window.location=url;

-igor


On Nov 9, 2007 7:37 AM, dd du <da...@gmail.com> wrote:
> Hi, igor, thanks for your response, I am not sure I understand what you
> mean, can you make it a little bit more specific or direct me to example or
> where to start to look at it? I am thinking to pass an url to javascript,
> when a button created from javascript is clicked, then direct it to the url,
> which points to a page generated in wicket, but this is not a short-cut way,
> also I am trying to download wicket source code to see how AjaxLink class is
> implemented since when an ajax link is clicked, the
> onClick(AjaxRequestTarget) method is called, maybe I can borrow some ideas
> there, but the wicket site has no source code to download, the release zip
> file does not contain the source code for wicket, only source code for the
> examples, any way to get the wicket open source code?
>
> Thanks
>
>
>
> On 11/9/07, Igor Vaynberg <ig...@gmail.com> wrote:
> >
> > there is no magic here. look at how Link#getURL() works - it generates
> > a url that invokes onLinkClicked on that Link component. you can use
> > much the same mechanism and pass that url to your javascript.
> >
> > -igor
> >
> >
> > On Nov 8, 2007 8:22 PM, dd du <da...@gmail.com> wrote:
> > > Hi, all,
> > > I am new to wicket, I have a question about calling javascript from
> > wicket,
> > > suppose I create a page from wicket, from this page I click a button,
> > which
> > > wicket will call a javascript function, this function will create a
> > dialog
> > > window with fancy GUI controls, from these controls, if I click one of
> > them,
> > > an event handler from that javascript file will be called, inside this
> > > handler, I need to call back to a wicket java method to handle business
> > > logic, now how can I do that? I know if wicket creates all the GUI
> > controls,
> > > wicket can handle the events easily, but I want javascript to create
> > them
> > > since it deals with fancy style sheets.
> > >
> > > Is there a way wicket can handle events generated from javascript
> > created
> > > buttons? or a way calling back to wicket java code from javascript code?
> > >
> > > Thanks
> > >
> > > David
> > >
> >
> > ---------------------------------------------------------------------
> > 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: Can wicket handle events generated from javascript created?

Posted by dd du <da...@gmail.com>.
Hi, igor, thanks for your response, I am not sure I understand what you
mean, can you make it a little bit more specific or direct me to example or
where to start to look at it? I am thinking to pass an url to javascript,
when a button created from javascript is clicked, then direct it to the url,
which points to a page generated in wicket, but this is not a short-cut way,
also I am trying to download wicket source code to see how AjaxLink class is
implemented since when an ajax link is clicked, the
onClick(AjaxRequestTarget) method is called, maybe I can borrow some ideas
there, but the wicket site has no source code to download, the release zip
file does not contain the source code for wicket, only source code for the
examples, any way to get the wicket open source code?

Thanks


On 11/9/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> there is no magic here. look at how Link#getURL() works - it generates
> a url that invokes onLinkClicked on that Link component. you can use
> much the same mechanism and pass that url to your javascript.
>
> -igor
>
>
> On Nov 8, 2007 8:22 PM, dd du <da...@gmail.com> wrote:
> > Hi, all,
> > I am new to wicket, I have a question about calling javascript from
> wicket,
> > suppose I create a page from wicket, from this page I click a button,
> which
> > wicket will call a javascript function, this function will create a
> dialog
> > window with fancy GUI controls, from these controls, if I click one of
> them,
> > an event handler from that javascript file will be called, inside this
> > handler, I need to call back to a wicket java method to handle business
> > logic, now how can I do that? I know if wicket creates all the GUI
> controls,
> > wicket can handle the events easily, but I want javascript to create
> them
> > since it deals with fancy style sheets.
> >
> > Is there a way wicket can handle events generated from javascript
> created
> > buttons? or a way calling back to wicket java code from javascript code?
> >
> > Thanks
> >
> > David
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Can wicket handle events generated from javascript created?

Posted by Igor Vaynberg <ig...@gmail.com>.
there is no magic here. look at how Link#getURL() works - it generates
a url that invokes onLinkClicked on that Link component. you can use
much the same mechanism and pass that url to your javascript.

-igor


On Nov 8, 2007 8:22 PM, dd du <da...@gmail.com> wrote:
> Hi, all,
> I am new to wicket, I have a question about calling javascript from wicket,
> suppose I create a page from wicket, from this page I click a button, which
> wicket will call a javascript function, this function will create a dialog
> window with fancy GUI controls, from these controls, if I click one of them,
> an event handler from that javascript file will be called, inside this
> handler, I need to call back to a wicket java method to handle business
> logic, now how can I do that? I know if wicket creates all the GUI controls,
> wicket can handle the events easily, but I want javascript to create them
> since it deals with fancy style sheets.
>
> Is there a way wicket can handle events generated from javascript created
> buttons? or a way calling back to wicket java code from javascript code?
>
> Thanks
>
> David
>

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