This content has been marked as final.
Show 3 replies
-
1. Re: a4j:support inside rich:dataTable
jucobb2 Jan 16, 2008 11:03 AM (in response to jucobb2)So here is what I am trying to do. I have a dataTable generated dynamically. And I want to add support for an onRowClick event. I have tried using an actionListener and the action event. I have no problem populating the data table, I just can't get any onRowClick actions to fire. Here is some example code
HtmlPanelGrid grid = new HtmlPanelGrid(); grid.setStyle("width:100%;"); grid.setColumns(1); HtmlDatascroller myScroll = new HtmlDatascroller(); myScroll.setId("dynamicdatascroller"); myScroll.setStyle("width:100%;"); myScroll.setTableStyle("width:100%;"); myScroll.setAlign("center"); myScroll.setFor("dynamicsearchtable"); myScroll.setMaxPages(20); grid.getChildren().add(myScroll); HtmlSpacer mySpacer = new HtmlSpacer(); mySpacer.setHeight("10"); grid.getChildren().add(mySpacer); // Create datatable. HtmlDataTable dynamicDataTable = new HtmlDataTable(); dynamicDataTable.setId("dynamicsearchtable"); dynamicDataTable.setOnRowMouseOver("this.style.backgroundColor='#F1F1F1'"); dynamicDataTable.setOnRowMouseOut("this.style.backgroundColor='#FFFFFF'"); dynamicDataTable.setRows(8); dynamicDataTable.setStyle("width:100%;"); dynamicDataTable.setValueExpression("value", createValueExpression("#{SearchBean.dynamicList}", List.class)); dynamicDataTable.setVar("dynamicItem"); HtmlAjaxSupport support = new HtmlAjaxSupport(); support.setAjaxSingle(true); support.setEvent("onRowClick"); support.setId("ajaxrowclick"); //Try and use an action event support.setActionExpression(createActionExpression("#{SearchBean.rowClickAction}", String.class)); // This is where i tried and use an actionlistener // RowClickEvent evt = new RowClickEvent(); // support.addActionListener(evt); dynamicDataTable.getChildren().add(support); grid.getChildren().add(dynamicDataTable); private MethodExpression createActionExpression(String actionExpression, Class<?> returnType) { FacesContext facesContext = FacesContext.getCurrentInstance(); return facesContext.getApplication().getExpressionFactory().createMethodExpression( facesContext.getELContext(), actionExpression, returnType, new Class[0]); }
-
2. Re: a4j:support inside rich:dataTable
ilya_shaikovsky Jan 17, 2008 6:48 AM (in response to jucobb2)you should add it as facet instead of as component.
-
3. Re: a4j:support inside rich:dataTable
jucobb2 Jan 17, 2008 10:50 AM (in response to jucobb2)I'll try adding the a4j:support using the facet tag. I wasn't aware it had to be done this way