How to trigger server-side method when user clicks on a Table Row

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to trigger server-side method when user clicks on a Table Row

 element (or the
duncan787
I am implementing a DataView using an HTML Table and I need to allow the user to select a row in the table to tell the Server Side which row they selected.  I could implement this by using AjaxFallbackLink, but this would only link the text in the row, the user needs to be able to click anywhere in the row, so I need the ability to detect when the user clicks anywhere in the row, like an onclick event on the
 elements).  Is there a way to tell the server side when this happens?  Here is my markup and I'm implementing DataView:

                <div wicket:id="projectListDataViewContainer">
                                                                                                                                                                       
 
                </div>

Thank you
duncan787
Reply | Threaded
Open this post in threaded view
|

submit or refresh form via ajax from javascript ?

Maris Orbidans


Is it possible to submit a form from javascript ?



Maris

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to trigger server-side method when user clicks on a Table Row

James Carman
In reply to this post by duncan787
Have you tried "attaching" your AjaxFallbackLink to your <tr> elements?

On Tue, Oct 12, 2010 at 6:27 AM, duncan787 <[hidden email]> wrote:

>
> I am implementing a DataView using an HTML Table and I need to allow the
> user
> to select a row in the table to tell the Server Side which row they
> selected.  I could implement this by using AjaxFallbackLink, but this would
> only link the text in the row, the user needs to be able to click anywhere
> in the row, so I need the ability to detect when the user clicks anywhere
> in
> the row, like an onclick event on the <TR> element (or the <TD> elements).
> Is there a way to tell the server side when this happens?  Here is my
> markup
> and I'm implementing DataView:
>
>                <div wicket:id="projectListDataViewContainer">
>                        <table>
>                            <tr wicket:id="siteProjectList">
>                                <td> </td>
>                                <td class="projectDesc"></td>
>                            </tr>
>                        </table>
>                </div>
>
> Thank you
> duncan787
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-trigger-server-side-method-when-user-clicks-on-a-Table-Row-tp2991576p2991576.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: submit or refresh form via ajax from javascript ?

jcgarciam
In reply to this post by Maris Orbidans
Simple javascript:

var theForm = document.getElementById("formId");
theForm.submit();




On Tue, Oct 12, 2010 at 7:53 AM, Maris Orbidans [via Apache Wicket] <[hidden email]> wrote:


Is it possible to submit a form from javascript ?



Maris

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]








--
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

Reply | Threaded
Open this post in threaded view
|

Re: How to trigger server-side method when user clicks on a Table Row

 element and add both an AjaxFallbackLink and a DataView to the container?

    DataView<SiteProject> projectListDataView =
        new DataView<SiteProject>("siteProjectList", getDataProvider(), 100)
    {
        @Override
        protected void populateItem(final Item<SiteProject> item)
        {
            SiteProject siteProject = item.getModelObject();
            item.add(new Label("ProjectDesc", siteProject.getProjectDesc()));
        }
    };
duncan787
In reply to this post by duncan787
Its already "attached" to the DataView, see the relevant/simplified Java code added below.  Would it best practice be to assign a WebMarkupContainer to the
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger server-side method when user clicks on a Table Row

jeremy@wickettraining.com
On Tue, Oct 12, 2010 at 8:25 AM, duncan787 <[hidden email]> wrote:

>
> Its already "attached" to the DataView, see the relevant/simplified Java
> code
> added below.  Would it best practice be to assign a WebMarkupContainer to
> the <TR> element and add both an AjaxFallbackLink and a DataView to the
> container?
>
>    DataView<SiteProject> projectListDataView =
>        new DataView<SiteProject>("siteProjectList", getDataProvider(), 100)
>    {
>        @Override
>        protected void populateItem(final Item<SiteProject> item)
>        {
>            SiteProject siteProject = item.getModelObject();
>            item.add(new Label("ProjectDesc",
> siteProject.getProjectDesc()));
>        }
>    };
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-trigger-server-side-method-when-user-clicks-on-a-Table-Row-tp2991576p2991852.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Nowhere in that code do you attach any ajax behavior that I see.

All you need is this (in your populate item method):

item.add(new AjaxEventBehavior("onclick") { ... onEvent(AjaxRequestTarget
target) { /* do something here */ } });

--
Jeremy Thomerson
http://www.wickettraining.com
Reply | Threaded
Open this post in threaded view
|

Re: submit or refresh form via ajax from javascript ?

jeremy@wickettraining.com
In reply to this post by jcgarciam
Did you mean AJAX submit (as your subject implied)?  Have you tried
AjaxFormSubmitBehavior?

On Tue, Oct 12, 2010 at 8:16 AM, jcgarciam <[hidden email]> wrote:

>
> Simple javascript:
>
> var theForm = document.getElementById("formId");
> theForm.submit();
>
>
>
>
> On Tue, Oct 12, 2010 at 7:53 AM, Maris Orbidans [via Apache Wicket] <
> [hidden email]<ml-node%[hidden email]>
> <ml-node%[hidden email]<ml-node%[hidden email]>
> >
> > wrote:
>
> >
> >
> > Is it possible to submit a form from javascript ?
> >
> >
> >
> > Maris
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=2991613&i=0>
> > For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=2991613&i=1>
> >
> >
> >
> > ------------------------------
> >  View message @
> >
> http://apache-wicket.1842946.n4.nabble.com/How-to-trigger-server-side-method-when-user-clicks-on-a-Table-Row-tp2991576p2991613.html
> > To start a new topic under Apache Wicket, email
> > [hidden email]<ml-node%[hidden email]>
> <ml-node%[hidden email]<ml-node%[hidden email]>
> >
> > To unsubscribe from Apache Wicket, click here<
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=
> >.
> >
> >
> >
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-trigger-server-side-method-when-user-clicks-on-a-Table-Row-tp2991576p2991835.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Jeremy Thomerson
http://www.wickettraining.com