-
1. Re: How to do something on rich:dataTable onRowClick
robertocarlos1 Jan 14, 2008 12:19 AM (in response to cfraser)you only need to use <a4j:support>, like you can see in the code above
<rich:dataTable width="483" binding="#{somebean.table}" id="mytable" value="#{somebean.datamodel}" rows="5" columnClasses="col" var="currentRow" onRowMouseOver="this.style.backgroundColor='#B5CEFD'" onRowMouseOut="this.style.backgroundColor=' {org.richfaces.SKIN.tableBackgroundColor}'"> ...... ...... <h:column> <h:outputText value="#{currentRow.somedata}"/> </h:column> ...... ...... <a4j:support ajaxSingle="true" status="statusIndicator" reRender="somecontrol,someothercontrol,..." actionListener="#{somebean.selectRow}" event="onRowClick"></a4j:support> ........ ........ </rich:dataTable>
the part marked as dark red is the way to execute some action when the onrowclick event is executed. the code in the backing to get the selected row look like this.package somepackage ..... public class SomeBean{ //this is needed for the binding property of the tag datatable private HtmlDataTable table = new HtmlDataTable(); //this is needed for the binding property of the tag datatable public void setTable(HtmlDataTable table){ this.table = table; } //this is needed for the binding property of the tag datatable public HtmlDataTable getTable(){ return this.table; } ... ... public void selectRow(ActionEvent ae){ SomeObject rowData = (SomeObject)getTable().getRowData(); ...... }
-
2. Re: How to do something on rich:dataTable onRowClick
cfraser Jan 15, 2008 4:41 PM (in response to cfraser)Thanks greatly for that... that got me going :-)
This is probably more a general JSF question, I have reduced the a4j:support tag to the following as I am not actually rendering on the same page... I am taking the selected row to a new page.
<a4j:support event="onRowClick" action="#{jobSearch.selectRow2}"></a4j:support>
Is this still the best way to move to a new page when a row is clicked given that it is not really an Ajax request?
Have looked at OnRowClick of the table, but not really sure what I should put there.
At least the above works, so thanks again.
Regards
Colin
Regards
Colin -
3. Re: How to do something on rich:dataTable onRowClick
robertocarlos1 Jan 15, 2008 9:35 PM (in response to cfraser)it is an ajax request, im not sure if this aproach is the best for move to other page. Im having problem with internet explorer when i move to other page using an AJAX request (The scripts are not loaded or not evaluated something like that is happen and that cause some javascript errors because some objects or functions are not loaded in the page), that is why i dont use ajax request for move to other pages. Posibly exist some solution to the problem, but for the moment i'm dont have so much time to investigate (I'm out of time with my project), so i dont use AJAX request to navigate to other pages for now
-
4. Re: How to do something on rich:dataTable onRowClick
jucobb2 Jan 15, 2008 11:23 PM (in response to cfraser)Did you have any luck on this? I have tried to put an a4j:support event for onRowClick in a datatable component. But no matter what I do I can't get the actionListener to do anything. If I use a javascript command for the onRowClick it works, but not in an a4j:support tag
-
5. Re: How to do something on rich:dataTable onRowClick
ilya_shaikovsky Jan 16, 2008 4:31 AM (in response to cfraser)are you sure that you request doens't failed with some conversion/validation errors?
use messages and a4j:log to check for possible server/client side problems.
About navigation from ajax requests - there should me no errors.. but use redirect for such nav cases to avoid problems. -
6. Re: How to do something on rich:dataTable onRowClick
mmichalek Jan 16, 2008 9:58 AM (in response to cfraser)I agree that it seems odd to use an ajax support component when you're not interested in doing ajax at all. Is anyone aware of a non-ajax solution?
I was able to get a "normal" page navigation to work though with ajax:support as suggested by this thread. I had to specifically use "action" instead of "actionListener" on a4j:support. I'm also using Seam, so I don't know if that helped out at all.<rich:dataTable value="#{value}" var="element"> <a4j:support event="onRowClick" action="#{component.someAction}" reRender="" /> ...
-
7. Re: How to do something on rich:dataTable onRowClick
robertocarlos1 Jan 16, 2008 10:39 AM (in response to cfraser)hi ilya_shaikovsky.
There aren't problems with validation errors. The problem is not in the source page, the problem is in the target page (The target page is loading but with errors, there aren't javascripts errors in the source page). when the target page load the first javascript error showed is Object Expected and follow other errors like Calendar is not defined or something like that.
For now i stop researching because i have to finish something for yesterday :) -
8. Re: How to do something on rich:dataTable onRowClick
robertocarlos1 Jan 16, 2008 10:41 AM (in response to cfraser)"JuCobb2" wrote:
Did you have any luck on this? I have tried to put an a4j:support event for onRowClick in a datatable component. But no matter what I do I can't get the actionListener to do anything. If I use a javascript command for the onRowClick it works, but not in an a4j:support tag
I'm don't using actionListener but it should work fine, you can try use action like is suggested above. -
9. Re: How to do something on rich:dataTable onRowClick
jucobb2 Jan 16, 2008 11:29 AM (in response to cfraser)Still doesn't work for me. I am creating my dataTable dynamically and have tried using action and actionListener.
I have another posting related to this topic here:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=127749
I hope someone can help me out on this. Seems like it should work. It just doesn't[/url] -
10. Re: How to do something on rich:dataTable onRowClick
ilya_shaikovsky Jan 17, 2008 6:35 AM (in response to cfraser)you sure you've used redirect for your nav case?
-
11. Re: How to do something on rich:dataTable onRowClick
robertocarlos1 Jan 17, 2008 9:59 AM (in response to cfraser)I dont using redirect, i will try to change the navigation case to redirect.
Thanks for your help -
12. Re: How to do something on rich:dataTable onRowClick
robertocarlos1 Jan 17, 2008 10:13 AM (in response to cfraser)Great!!
move to other page using AJAX request is working fine, after mark the navigation case as redirect.
Thanks a lot.