-
1. Re: Capturing the rowdata of a DataTable
baz Jun 27, 2007 12:29 AM (in response to richfacesuser)Please read this:
http://jboss.com/index.html?module=bb&op=viewtopic&t=111455 -
2. Re: Capturing the rowdata of a DataTable
richfacesuser Jun 27, 2007 9:25 AM (in response to richfacesuser)Thanks very much for the reply.
Could you please tell me what does the binding method
binding=""#{ajaxhelper.table} do. If you provide me with a snippet of the bean including the imports for getTable and ActionEvent that will be greatly appreciated.
Thanks again -
3. Re: Capturing the rowdata of a DataTable
richfacesuser Jun 28, 2007 4:45 PM (in response to richfacesuser)Thanks for the info Carsten.
I have modified my page and bean as specified in the example.
The code snippet is as follows.
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich" %>
<%@taglib prefix="a4j" uri="https://ajax4jsf.dev.java.net/ajax" %>
<f:view>
<a4j:form>
<rich:dataTable styleClass="table" style="width: 39pc; padding-left: 0px; left: 0px; margin-left: 0px; text-align: center; clip: rect(auto, auto, auto, 0px); vertical-align: middle"
onRowClick="onRowClick(this)"
onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
cellpadding="0" cellspacing="0" id="record" rows="10" var="record" value="#{beanA.Lists}" >
<a4j:support event="onRowClick" actionListener="#{beanA.rowSelected}"/>
<f:facet name="header">
<rich:columnGroup>
<rich:column>
<h:outputText value="#{msgs['paddress']}" />
</rich:column>
<rich:column>
<h:outputText value="#{msgs['city']}" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:columnGroup>
<rich:column style="white-space: nowrap;" >
<h:outputText value="#{record.primaryaddress}"></h:outputText>
</rich:column>
<rich:column>
<h:outputText value="#{record.city}"></h:outputText>
</rich:column>
</rich:columnGroup>
</rich:dataTable>
</a4j:form>
</f:view>
ANd my bean beanA looks like
................................
RowData rowData = new RowData();
private UIDataTable table;
public void rowSelected(ActionEvent event) {
System.out.println("rowSelected");
Integer currIndex = getTable().getRowIndex();
List allData = (List) getTable().getValue();
this.rowData = (RowData) allData.get(currIndex);
System.out.println("@#@#@#@#@#@#@: ROW: "+ rowData.getPrimaryAddress()+" "+rowData.getCity()+" "+rowData.getZip());
}
public UIDataTable getTable() {
return table;
}
public void setTable(UIDataTable table) {
this.table = table;
}
Here the control is never invoking the rowSelected method.
The statement "System.out.println("rowSelected");" is not getting executed on the row click.
Whenever I am clicking on any row in the datatable, an error message "Error on Page" is displayed in the status bar of the Internet Explorer.
Any help is highly appreciated.
Thank you -
4. Re: Capturing the rowdata of a DataTable
ilya_shaikovsky Jun 29, 2007 7:03 AM (in response to richfacesuser)1)you still have no binding to table. It's important to get clicked row.
simple example of getting clicked row is
http://livedemo.exadel.com/a4j-repeat/
source is at
http://webdownload.exadel.com/downloads/ajax4jsf/examples/a4j-repeat/a4j-repeat.zip
2) Please explore the client error with some client debugger to get the more info. -
5. Re: Capturing the rowdata of a DataTable
j-pro Sep 20, 2007 4:09 PM (in response to richfacesuser)Good afternoon.
I read some information here on the forum about how users try to make actions while clicking on a row in the DataTable. I tried to make it by myself using your suggestions and advices. But I've got an exception about illegal argument in binding param of the rich:dataTable. But what type should it be?
I make it as:<rich:dataTable style="width:167px" id="employeesDataTable" rows="20" binding="#{amBean.table}" columnsWidth="98%,1%,1%" onRowClick="this.style.backgroundColor='#F1F1F1'" onRowMouseOver="this.style.backgroundColor='#B5CEFD'" onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'" cellpadding="0" cellspacing="0" value="#{amBean.employeeListMan.employees}" var="item"> <a4j:support event="onRowClick" actionListener="#{amBean.rowSelected}"/> </rich:dataTable> ...
And in managed bean:... import org.richfaces.component.UIDataTable; ... private UIDataTable table; ... public UIDataTable getTable() { return table; } public void setTable(UIDataTable table) { this.table = table; } ... public void rowSelected(ActionEvent event) { System.out.println("======>>>>>> rowSelected invoked"); Integer currIndex = getTable().getRowIndex(); List allData = (List) getTable().getValue(); Employee rowData = new Employee(); rowData = (Employee)allData.get(currIndex); System.out.println("Data: "+ rowData.getFirstName()+" "+rowData.getLastName()+" "+rowData.getEmployeeId()); } ...
And after all this I have:javax.el.ELException: /index.xhtml @26,15 binding="#{amBean.table}": java.lang.IllegalArgumentException: argument type mismatch
Can you give any advices to me please, what I'm doing wrong?
Thank you very much in advance. -
6. Re: Capturing the rowdata of a DataTable
ilya_shaikovsky Sep 21, 2007 6:07 AM (in response to richfacesuser)<a4j:support event="onRowClick" actionListener="#{capitalsBean.actionListener}"/>
private HtmlDataTable table = new HtmlDataTable(); public void actionListener(ActionEvent event) { System.out.println(getTable().getRowKey().toString() + "clicked"); }
Works fine for me. -
7. Re: Capturing the rowdata of a DataTable
j-pro Sep 21, 2007 10:14 AM (in response to richfacesuser)"ilya_shaikovsky" wrote:
...
Works fine for me.
Strange... I've changed UIDataTable to org.richfaces.component.html.HtmlDataTable and got the same exception. Then I made clean+rebuild and started getting this:/index.xhtml @540,59 onRowMouseOver="this.style.backgroundColor='#B5CEFD'" object is not an instance of declaring class
I should notice that it's far away from the place in the code where my first dataTable for employees is. And I'm trying to control rowClick only in employees table. But in the line 540 and around there are:533 <h:form id="relativesTab_dataTableForm"> 534 <rich:dataTable 535 id="relativesDataTable" 536 onRowClick="this.style.backgroundColor='#F1F1F1'" 537 onRowMouseOver="this.style.backgroundColor='#B5CEFD'" 538 onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'" 539 cellpadding="0" cellspacing="0" style="width:100%" 540 value="#{amBean.employee.relativeList}" var="rudele"> <rich:column> <h:outputText value="#{rudele.relativeId}" /> </rich:column> ...
I removed all "onRowClick="this.style.backgroundColor='#F1F1F1'"" from my xhtml-file and made rebuild. The exception keeps appearing.
This exception only disappears when I remove "binding="#{amBean.table}"" and "<a4j:support event="onRowClick" actionListener="#{amBean.rowSelected}"/>" from my first dataTable for employees (its code is listed above).
What it could be? I use RF 3.1.0 with JBoss 4.2.0.GA.
Thank you very much. -
8. Re: Capturing the rowdata of a DataTable
ilya_shaikovsky Sep 24, 2007 7:27 AM (in response to richfacesuser)I'm using 3.1.1.. Can you try to update to check?
-
9. Re: Capturing the rowdata of a DataTable
j-pro Sep 24, 2007 10:19 AM (in response to richfacesuser)"ilya_shaikovsky" wrote:
I'm using 3.1.1.. Can you try to update to check?
Sure! Thanks for your reply.
Updated to richfaces-ui-3.1.1-SNAPSHOT - the same exception:/index.xhtml @540,59 onRowMouseOver="this.style.backgroundColor='#B5CEFD'" object is not an instance of declaring class
and it still only disappears when I remove "binding="#{amBean.table}"" and "<a4j:support event="onRowClick" actionListener="#{amBean.rowSelected}"/>" from my first dataTable for employees (its code is listed above). -
10. Re: Capturing the rowdata of a DataTable
j-pro Sep 24, 2007 10:32 AM (in response to richfacesuser)By the way - the same is with richfaces-ui-3.2.0-SNAPSHOT...
Maybe I'm doing something wrong?
I have EAR, where are:
1. war - my webapp, where RF is used.
2. jar - my business logic with EJB. That's where my amBean is from.
I've copied three jars from RF to JBoss\server\default\lib\", added it from this location into BOTH of war and jar build classpaths, rebuild all the project, restarted the server and redeployed EAR.
Is it right? -
11. Re: Capturing the rowdata of a DataTable
ilya_shaikovsky Sep 24, 2007 11:01 AM (in response to richfacesuser)create a war file for me please. I'll write an answer here then.
-
12. Re: Capturing the rowdata of a DataTable
j-pro Sep 24, 2007 11:20 AM (in response to richfacesuser)Thanks for helping me, Ilya.
My EAR-file with jar and war inside was sent to your e-mail. Hope it helps to solve my problem.
Thank you again in advance. -
13. Re: Capturing the rowdata of a DataTable
j-pro Sep 25, 2007 10:40 AM (in response to richfacesuser)Ilya, do you have any suggestions?
-
14. Re: Capturing the rowdata of a DataTable
maksimkaszynski Sep 25, 2007 11:29 AM (in response to richfacesuser)I have strong feeling that JBoss AS caches some older copies of resources. I'll check. Ilya's already gone, tomorrow he'll give me your app war, I'll check.