-
1. Re: Problem with events in a rich:dataTable
dune89 Dec 16, 2011 9:09 AM (in response to dune89)There is a second question, how can i get access on an Event on the CDI Bean
<a4j:ajax event="rowdblclick" listener="#{dummy.doSth()}" />
and
public void doSth(ActionEvent e)
does not work...
Best Regards
Matthias
-
2. Re: Problem with events in a rich:dataTable
mcmurdosound Dec 17, 2011 4:10 AM (in response to dune89)It seems like a bug. A workaround for now could be setting the switchType to "client" in the collapsable panel. (then there won't be any posts on (de-)collapsing the panel.
<rich:collapsiblePanel switchType="client">
<rich:dataTable value="#{myMBean.allCustomers}" var="iterator" >
<f:facet name="header">
<rich:column>Parameter:</rich:column>
</f:facet>
<rich:column>
<h:outputText value="#{iterator}" style="font-family:Courier New;" />
</rich:column>
<a4j:ajax event="rowdblclick" listener="#{myMBean.doSomething()}" />
</rich:dataTable>
</rich:collapsiblePanel>
-
3. Re: Problem with events in a rich:dataTable
dune89 Dec 19, 2011 12:47 AM (in response to mcmurdosound)Thanks Christian,
your workaround works. Do i have to create a Ticket or something or this Bug is already known ?
Can you tell me how it is possible to get acces to the event in my bean. After dblclicking i want to check wich row is clicked an i think i need the UIComponent isnt it ?
Best Regards
Matthias Hinderkott
-
4. Re: Problem with events in a rich:dataTable
mcmurdosound Dec 19, 2011 4:29 AM (in response to dune89)public void myListener(AjaxBehaviorEvent event){
System.out.println("event" + event);
System.out.println("XXXXXXXXXXXXX");
UIDataTable table = (UIDataTable) event.getSource();
AjaxBehavior behavior = (AjaxBehavior) event.getBehavior();
System.out.println("table: " + table);
System.out.println("behavior: " + behavior);
System.out.println("data: " +behavior.getData());
System.out.println("row: " + table.getRowIndex());
}
Facelet:
...
<rich:dataTable id="tbl" value="#{myMBean.allCustomers}" var="iterator" rowKeyVar="rowk" >
<f:facet name="header">
<rich:column>Parameter:</rich:column>
</f:facet>
<rich:column>
<h:outputText value="#{iterator}" style="font-family:Courier New;" />
</rich:column>
<a4j:ajax event="rowdblclick" data="#{iterator}" listener="#{myMBean.myListener}" />
</rich:dataTable>
Maybe you'll find some usable values in the AjaxBehaviorEvent. "Row" returns the current index of the row.
More interesting is the DATA: it gives the actual selected Object! In my case it's the rows customer entity.
-
5. Re: Problem with events in a rich:dataTable
dune89 Dec 19, 2011 6:23 AM (in response to mcmurdosound)Hey Christian thanks for your great help!
You say the intresting part is the getData, this method returns "null" on every row i select :/. Ist correct that the behavior class is from package
import org.ajax4jsf.component.behavior.AjaxBehavior; ? You have an idea why getData returns null ?
The getRowIndex or getRowData or getRowKey seams to work wrong with data scrollers :/ .
For example i have 10 Tupels in my dataTable i configured the table with rows="3" and my table got a data scroller
<f:facet name="footer">
<rich:dataScroller id="scroller" for="txtListe" >
</rich:dataScroller>
</f:facet>
</rich:dataTable>
so if i click on Page 2 row 2 it would be Index 4 (0,1,2 - 3,4,5 - 6,7,8) but it returns 1 Is that behavior correct ??
Best Regards
Matthias
-
6. Re: Problem with events in a rich:dataTable
dune89 Dec 19, 2011 6:55 AM (in response to dune89)Hm i found something but i dont think that this is the prefered ^^ can u tanke a look at this
UIDataTable table = (UIDataTable) event.getSource();
SequenceRange range = (SequenceRange) table.getComponentState().getRange();
System.out.println(range.getFirstRow()+table.getRowIndex());
-
7. Re: Problem with events in a rich:dataTable
mcmurdosound Dec 19, 2011 10:56 AM (in response to dune89)So, I've tried with your code snippets. But, strangely enough, it seems to work, but only on the first page. If I change the page with the datascroller and select a row on the new page, "data" still returns the objects from the first page! This could be also a bug or we are using it wrong. The rowIndex is still the same for every page.
System.out.println(range.getFirstRow()+table.getRowIndex());
return the correct index in the table. But if you have clientside filtering / sorting, you'll have to keep that in mind, too.
-
8. Re: Problem with events in a rich:dataTable
mcmurdosound Dec 19, 2011 11:24 AM (in response to mcmurdosound)1 of 1 people found this helpfulI've got another workaround ;-) :
<rich:dataTable id="tbl" value="#{myMBean.allCustomers}" var="iterator" rowKeyVar="rowk"
rows="5">
<f:facet name="header">
<rich:column>Parameter:</rich:column>
</f:facet>
<rich:column>
<h:outputText value="#{iterator}" style="font-family:Courier New;" />
<a4j:commandLink value="select" action="#{myMBean.editCustomer(iterator)}"
execute="@this"
style="display:none !important;"/>
</rich:column>
<f:facet name="footer">
<rich:dataScroller id="scroller" for="tbl" oncomplete="initRowSelect();">
</rich:dataScroller>
</f:facet>
</rich:dataTable>
You'll recognize the hidden a4j:commandLink in the column. This one will execute the editCustomer(Customer c) method in the bean. This works and you'll get the currentrows customer.
The link is intentionally hidden. But how to call it? Use jQuery and bind an dblclick event on each row!
<script>
var initRowSelect = function (){
jQuery(".rf-dt-r").bind("dblclick", function(){
console.log(this);
jQuery(this).find("a:first").click();
});
}
jQuery(document).ready(function(){
initRowSelect();
});
</script>
I think, you'll have to fix the selector - especially if you have more than one table on one page.
-
9. Re: Problem with events in a rich:dataTable
dune89 Dec 20, 2011 4:50 AM (in response to mcmurdosound)Hey Christian,
thanks for this great idea im a complete newbee in jQuery but i got it.
I used the jQuery function of RichFaces and it works
Here my code snippet:
<rich:dataTable value="#{dummy.myModel}" var="iterator" rows="8" styleClass="stable">
.....
<rich:column style="width:500px">
<h:outputText value="#{iterator.erlaeuterung}" />
<a4j:commandLink value="select" action="#{dummy.doSthMoreMore(iterator)}"
execute="@this" style="display:none !important;" styleClass="hlp"/>
</rich:column>
.....
</rich:dataTable>
<rich:jQuery selector=".stable tbody tr" event="click" query="jQuery(this).find('.hlp')[0].click()"/>
I think that way is much better than my old with calculating an id via (range.getFirstRow()+table.getRowIndex()); ^^
What do you think we shold create a BugReport or sth. for this both "Bugs" ?
Best Regards
Matthias
-
10. Re: Problem with events in a rich:dataTable
logan.mauzaize.infotel.com Jan 25, 2012 9:11 AM (in response to dune89)Hi,
I confirm the first problem. I have resolved it by patching the org.richfaces.renderkit.DataTableRenderer class.
It happens when "decoding" Rich data table whereas there's no behavior event. In this case there's no request parameter named "javax.faces.behavior.event". So parameter value must be "null"-checked before testing it's starting by "row".
I suspect it reproduce each time a rich data table is submitted whereas there's no behavior event. A possible work around can be to place a region around components in the form for excluding the table and provides a well-filled execute attribute on a4j:ajax (or a4j:command*).
CAUTION: I haven't tested this solution as the simple patch works fine.
-
11. Re: Problem with events in a rich:dataTable
fmt Feb 10, 2012 11:08 AM (in response to logan.mauzaize.infotel.com)Hi,
This error shows up as soon as there are a rich:dataTable with a4j:ajax attached in the page...
Example:
<rich:dataTable ...>
<a4j:ajax event="rowclick" listener="..." />
...
</rich:dataTable>
<h:commandButton action="..." value="..." />
A click on the button will show the error. This is quite a huge bug for me !
Is there already an issue filled ?
Regards,
Florian Minjat
-
12. Re: Problem with events in a rich:dataTable
logan.mauzaize.infotel.com Feb 10, 2012 11:16 AM (in response to fmt)Hi F M,
Have you try to replace your h:commandButton with a a4j:commandButton and filled the "execute" attribute in order to exclude your table from the restore view phase ?
Is there already an issue filled ?
I don't think so. At top of the topic you can see that there's no issue attach to this thread ...
-
13. Re: Problem with events in a rich:dataTable
fmt Feb 13, 2012 10:51 AM (in response to logan.mauzaize.infotel.com)Hi,
Yes it works with a4j:commandButton with execute=@this.
But this is rather problematic on big pages with templates as the error isn't easily understandable !
The normal h:commandButton should work, and it should be possible to also submit the table: we had with JSF1.2 the need to submit a table with input in the rows. I don't think it'll be possible with this error...
Regards,
Florian Minjat
-
14. Re: Problem with events in a rich:dataTable
logan.mauzaize.infotel.com Feb 13, 2012 10:59 AM (in response to fmt)As I mention in my first message, I have patched the org.richfaces.renderkit.DataTableRenderer class.
On RF 4.1, it consits in adding null check on line 113. Like this :
Map<String, String> parametersMap = context.getExternalContext().getRequestParameterMap(); final String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME); if (behaviorEvent == null || !behaviorEvent.startsWith(ROW)) { return; }
I join the patched file.
Just add it to the /WEB-INF/classes of your web application. Your container must take it prior to the JAR bundled one.
-
DataTableRenderer.java.zip 3.8 KB
-