-
1. Re: onclick event on datatable row with richfaces 4
mp911de Oct 11, 2011 12:54 AM (in response to haukegulich)Hi Hauke,
try following statement in your code to get it running:
public void selectActiveLight() {
UIDataTable component = (UIDataTable) FacesContext.getCurrentInstance().getViewRoot()
.findComponent("form:lichtListe");
String selectedRow = component.getRowData().toString();
System.out.println("Selected Light : " + selectedRow);
model.setSelectedLight(selectedRow);
}
<h:form id="form">
<a4j:outputPanel id="in">
<rich:dataTable value="#{model.messages}" var="licht" width="100%"
id="lichtListe" columns="2">
<rich:column>
<f:facet name="header">
<h:outputText value="Beschreibung" />
</f:facet>
<a4j:commandLink value="#{licht}" render="testingID"
action="#{controller.selectActiveLight}">
</a4j:commandLink>
</rich:column>
</rich:dataTable>
<h:outputText value="This is the id : #{model.selectedLight}"
id="testingID"></h:outputText>
</a4j:outputPanel>
</h:form>
I changed the model for my testing purposes.
Best regards,
Mark
-
2. Re: onclick event on datatable row with richfaces 4
haukegulich Oct 11, 2011 2:15 AM (in response to mp911de)Hi Mark,
I will try that later today as soon as I am home from work, but looking at your code it seems that you put a link inside the dataTable. <a4j:commandLink> but I want something like this:
first table on top of the page has a list with customers (name, firstname, street and city). Now if I click on any of those columns (name, firstname ...) a second table (at the bottom) should display the details of the selected customer.
So the function with 'onclick' should be available to the whole cell and not only for the text within the cell and it shouldn't be make any difference in which cell you click on each row.
I did that with richface 3 like I posted before with
<a4j:support> within the rich:column tag and that for each column inside the dataTable.
the a4j:support tag had the onclick event with the listener and a f:attribute for the value I could read inside the listener method. That worked really good.
But I will try your example. Maybe I missed something in your code.
Greetings,
Hauke
-
3. Re: onclick event on datatable row with richfaces 4
rcordoba Jan 17, 2013 1:15 PM (in response to haukegulich)Hi Hauke,
did you manage to solve your problem? I have the same problem.
Actually, if I do next, it doesn´t work:
<rich:column styleClass="columna" id="paisColumna" label="#{msj.pais}" >
<a4j:ajax event="change" listener="#{I18nBean.setPais}" status="esperaStatus" render="panelBuscarCharter" />
</rich:column>
Bean:
public void setPais(AjaxBehaviorEvent event) {
locale = new Locale("en");
FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
}
but if I do this (put the ajax call inside selectBooleanCheckBox in example, it works (with the same bean) :
<rich:column styleClass="columna" id="paisColumna" label="#{msj.pais}" >
<h:selectBooleanCheckbox id="mismoPuerto3" value="#{InicioBean.mismoPuerto}" class="perrisCheckbox">
<a4j:ajax event="change" listener="#{I18nBean.setPais}" status="esperaStatus" render="panelBuscarCharter" />
</h:selectBooleanCheckbox>
</rich:column>
I hope you can help me.
Thanks,
Roberto.
-
4. Re: onclick event on datatable row with richfaces 4
champagne Apr 27, 2016 1:35 AM (in response to haukegulich)In RichFaces 4.x, <a4j:ajax> can't work under <rich:column> element directly, because the component of <rich:column> doesnt' implement javax.faces.component.behavior.ClientBehaviorHolder interface.
Move <a4j:ajax> to under the <rich:dataTable> element directly will be fine.