Table row selection in generated columns.

Hi have a Table which has generated columns containg different layouts. when any user clicks on these generated columns i should first make the Table row “SELECTED” i.e. the background colour should change for the entire row and after a delay of 1000millisecond i should take the user to a new view. Now i have implemented the LayoutClickListener on the generated columns. But the table row selection is not done immedietly. Only when the user returns back to the table view I see that the row is selected. Just out of curiosity what is the event that changes the background colour of the table row? Here is the code

dailyTasksTable.addListener(new ItemClickEvent.ItemClickListener() {

		public void itemClick(ItemClickEvent event) {

			DailyTask task = (DailyTask) event.getItemId();
			if (event.getPropertyId().equals("visitInfo")
					|| ((event.getPropertyId().equals("serviceTypeInfo")))) {
				
				navigateToClientView(task);
			}
		}
	});

public void navigateToClientView(DailyTask task) {

logger.info("Selecting Table row Going to Client View");
dailyTasksTable.select(task);
try {
   Thread.sleep(1000);
} catch (InterruptedException e) {
	e.printStackTrace();
}
presenter.navigateToClientView(task);
}

Note My Layout click listener implementation directly calls navigateToClientView(DailyTask task) in the genrated columns. Even then i dont see the table row selection first.
Any help…

Since you’re placing components inside the table cells – and layouts with click listener even more so – click events aren’t propagated to the table component, hence preventing the table row selection. The row selection/hilite is done in the client using regular click events, after which the selection change event is sent to the server.

Instead of using a LayoutClickListener, why not just use either the regular ValueChangeListener for the table (which would then allow keyboard navigation for the table as well, not just mouse) or ItemClickListener, which I think might work better and allow the row hilite as well (not sure though).

Thanks Juoni for your reply

Infact I am using ItemClickListener to listen to click events. I had to use Layout clciklisteners inside my generated column layouts becouse when i click on the generated column layouts ItemClcikListener event is not getting fired. So inorder to enable clcikevents on generated layout i had to use LayoutClckListener. Is there any way for me to call the client side event that makes the row selected on my generated components.

Hi!

No, unfortunately there is no such a way to interact with client-side from the server-side code. But you can use
Refresher add-on
to add some delay before the next view will open.

With Refresher, you can try something like this: In your itemClick-method, first select the new value for dailyTasksTable. After that, enable Refresher with 1000ms refresh interval. Add a RefreshListener to your Refresher that will - when invoked - stop refreshing and navigate to the other view.

Thanks Tomi

Inducing a delay is not a problem for me. Table row selection is the main problem. The Table row does not gets selected if i click on mu generated column layouts.
Also i don’t think i am allowed to use any addon in the current project. Any thanks again.

I understand that row selection is the main problem here. As Jouni wrote, click events aren’t propagated to the table component. Using Refresher is just a workaround for that. Doing the same thing without any add-on can be done with a
ProgressIndicator
component too. Component just needs to be set invisible in you view. See a sample code at the end of the chapter 12.2 at
Vaadin Book.
.

Thanks Tomi

The workaround you suggested worked really well. Thanks again, Will propose this solution to the architects if the approve then we may use the addon. I have an Eclipse
version of our application here in India and the actual Code is hosted in Finland(Turku) servers. So here in eclipse everything was taken care by the Vaadin plugin installed in my eclipse. What are the things that i were to take care of to successfully package the refresher addon onto the server machines in Finland. There we use Jdeveloper(10.1.3) which does not have any kind of support for vaadin.

Thanks in advance
Ajay

All that it needs are files under the WebContent/VAADIN directory that are generated when you compile your Vaadin widgetset. Plus the add-on JAR file. I don’t know where these files should be placed in your project, but finally all widgetset files in VAADIN directory needs to be placed in VAADIN directory in your web application’s WAR package and add-on JAR should be in WEB-INF/lib directory.

And finally check the WEB-INF/web.xml deployment descriptor and see that the servlet for your application has a widget set parameter, such as the following:


<init-param>
  <description>Application widgetset</description>
  <param-name>widgetset</param-name>
  <param-value>com.example.myproject.widgetset.MyprojectWidgetset</param-value>
</init-param>

You can also use IDE independent ANT to compile Widget Set. Read more at
Book of Vaadin Chapter 10.3.2.

Hey Ranjit,

Not sure what you mean with “get enabled”?

If you want to listen to selection changes in the table you can do with:

table.setSelectable(true);
table.addValueChangeListener(new ValueChangeListener() {
  public void valueChange(ValueChangeEvent event) {
    // code here
  }
});

If neither of the above helps, please clarify what the problem is.

Hi Joacim,
Thanks for your reply but i had resolved that issue myself.The thing is if i click on the table row the other components that i added into my layout should get enabled that is present in the second component of HorizontalSplitPanel.Anyway thanks for your reply