views:

117

answers:

2

I've been googling this question a lot and I dont seem to find a solution. I wonder if any developer out there that able to achieve this? I know there are couple ajax framework out there for JSF like Richfaces, primefaces, icefaces ... I have look at their showcase, and could not seems to find what I am looking for.

+1  A: 

Richfaces has native support for jQuery using rich:jQuery component. You can use any effects that jQuery supports. For example:

<h:commandButton id="submitButton" value="Submit" 
   action="#{myBean.myAction}" style="display: none;"/>
<rich:jQuery selector="#submitButton" 
   query="fadeIn('slow')" timing="onload">

or

<h:commandButton id="submitButton" value="Submit" 
   action="#{myBean.myAction}" 
   onmouseover="jQuery(this).fadeOut('slow');" 
   onmouseout="jQuery(this).fadeIn('slow')"/>

You can find more examples here: http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_jQuery.html

theorm
All good and nice, but this doesn't answer the actual question. Please post a snippet/example which demonstrates exactly the functional requirement as described by the OP. It's a pretty tricky one (let's assume that a `dataTable` is been used as table to insert the new row in). PrimeFaces by the way wraps all this particular jQuery verbosity in a [`p:effect`](http://www.primefaces.org/showcase/ui/effects.jsf) component, among others.
BalusC
@BalusC Makes sense. Posted another example.
theorm
+2  A: 

This is how it would work for h:dataTable assuming that we always append to the table:

<h:form>
 <h:panelGroup id="animatedTableGroup">
  <h:dataTable id="animatedTable" value="#{myBean.rows}" var="row">
   <h:column>
    <h:outputText value="#{row}"/>
   </h:column>
  </h:dataTable>
  <rich:jQuery timing="onload" 
        selector="#animatedTable tr:last" query="fadeOut('slow')"/>
  <rich:jQuery timing="onload" 
        selector="#animatedTable tr:last" query="fadeIn('slow')"/>
 </h:panelGroup>

 <a4j:commandButton value="Add row" 
      action="#{myBean.addRow}" reRender="animatedTableGroup"/>
</h:form>

And the bean:

public void addRow() {
  rows.add(new Date().toString());
}

public List<String> getRows() {
  return rows;
}

If you want to insert into selected position in the table, then it's better to use rich:extendedDataTable and use something like this as selector:

<rich:jQuery timing="onload" 
        selector="#animatedTable tr.rich-sdt-row-selected" query="..."/>
theorm
I don't have RichFaces at hand but this look like that it will work. Did you test it in practice?
BalusC
@BalusC Yes, tested. It works.
theorm