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

2010-10-12 Thread James Carman
Have you tried attaching your AjaxFallbackLink to your tr elements?

On Tue, Oct 12, 2010 at 6:27 AM, duncan787 duncan...@gmail.com 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: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




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

2010-10-12 Thread 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 TR element and add both an AjaxFallbackLink and a DataView to the
container?

DataViewSiteProject projectListDataView = 
new DataViewSiteProject(siteProjectList, getDataProvider(), 100)
{
@Override
protected void populateItem(final ItemSiteProject 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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



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

2010-10-12 Thread Jeremy Thomerson
On Tue, Oct 12, 2010 at 8:25 AM, duncan787 duncan...@gmail.com 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?

DataViewSiteProject projectListDataView =
new DataViewSiteProject(siteProjectList, getDataProvider(), 100)
{
@Override
protected void populateItem(final ItemSiteProject 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: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


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