<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: JSF 2, h:dataTable, and Ajax Updates</title> <atom:link href="http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/feed/" rel="self" type="application/rss+xml" /><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/</link> <description></description> <lastBuildDate>Mon, 06 Feb 2012 08:22:23 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Jason Lee</title><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/comment-page-1/#comment-8589</link> <dc:creator>Jason Lee</dc:creator> <pubDate>Mon, 08 Mar 2010 15:07:05 +0000</pubDate> <guid
isPermaLink="false">http://blogs.steeplesoft.com/?p=520#comment-8589</guid> <description>Kent, sorry about that.  Here&#039;s the source for DataAccessController.  It&#039;s a pretty simple class, which, iirc, is based pretty heavily on some auto-generated code from NetBeans. :)&lt;pre&gt;&lt;code&gt;
public class DataAccessController implements Serializable {@PersistenceContext(name = &quot;em&quot;)
protected EntityManager em;
@Resource
private UserTransaction utx;public &lt;T&gt; void create(T entity) {
try {
utx.begin();
em.persist(entity);
utx.commit();
} catch (Exception e) {
try {
utx.rollback();
} catch (SystemException ex) {
//
}
throw new RuntimeException(e);
}
}public &lt;T&gt; void edit(T entity) {
try {
utx.begin();
em.merge(entity);
utx.commit();
} catch (Exception e) {
try {
utx.rollback();
} catch (SystemException ex) {
//
}
throw new RuntimeException(e);
}
}public &lt;T&gt; void remove(T entity) {
try {
utx.begin();
em.remove(em.merge(entity));
utx.commit();
} catch (Exception e) {
try {
utx.rollback();
} catch (SystemException ex) {
//
}
throw new RuntimeException(e);
}
}public &lt;T&gt; T find(Class&lt;T&gt; clazz, Object id) {
return em.find(clazz, id);
}public Query createQuery(String query) {
return em.createNamedQuery(query);
}public &lt;T&gt; List&lt;T&gt; findAll(Class&lt;T&gt; clazz) {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(clazz));
return em.createQuery(cq).getResultList();
}public &lt;T&gt; List&lt;T&gt; findRange(Class&lt;T&gt; clazz, int begin, int end) {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(clazz));
Query q = em.createQuery(cq);
q.setMaxResults(end - begin);
q.setFirstResult(begin);
return q.getResultList();
}public &lt;T&gt; int count(Class&lt;T&gt; clazz) {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root&lt;T&gt; rt = cq.from(clazz);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
}
}
&lt;/code&gt;&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>Kent, sorry about that.  Here&#8217;s the source for DataAccessController.  It&#8217;s a pretty simple class, which, iirc, is based pretty heavily on some auto-generated code from NetBeans. <img
src='http://blogs.steeplesoft.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><pre><code>
public class DataAccessController implements Serializable {

    @PersistenceContext(name = "em")
    protected EntityManager em;
    @Resource
    private UserTransaction utx;

    public <t> void create(T entity) {
        try {
            utx.begin();
            em.persist(entity);
            utx.commit();
        } catch (Exception e) {
            try {
                utx.rollback();
            } catch (SystemException ex) {
                //
            }
            throw new RuntimeException(e);
        }
    }

    public </t><t> void edit(T entity) {
        try {
            utx.begin();
            em.merge(entity);
            utx.commit();
        } catch (Exception e) {
            try {
                utx.rollback();
            } catch (SystemException ex) {
                //
            }
            throw new RuntimeException(e);
        }
    }

    public </t><t> void remove(T entity) {
        try {
            utx.begin();
            em.remove(em.merge(entity));
            utx.commit();
        } catch (Exception e) {
            try {
                utx.rollback();
            } catch (SystemException ex) {
                //
            }
            throw new RuntimeException(e);
        }
    }

    public </t><t> T find(Class</t><t> clazz, Object id) {
        return em.find(clazz, id);
    }

    public Query createQuery(String query) {
        return em.createNamedQuery(query);
    }

    public </t><t> List</t><t> findAll(Class</t><t> clazz) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(clazz));
        return em.createQuery(cq).getResultList();
    }

    public </t><t> List</t><t> findRange(Class</t><t> clazz, int begin, int end) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(clazz));
        Query q = em.createQuery(cq);
        q.setMaxResults(end - begin);
        q.setFirstResult(begin);
        return q.getResultList();
    }

    public </t><t> int count(Class</t><t> clazz) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root</t><t> rt = cq.from(clazz);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }
}
</t></code></pre>]]></content:encoded> </item> <item><title>By: Kent</title><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/comment-page-1/#comment-8588</link> <dc:creator>Kent</dc:creator> <pubDate>Mon, 08 Mar 2010 14:58:14 +0000</pubDate> <guid
isPermaLink="false">http://blogs.steeplesoft.com/?p=520#comment-8588</guid> <description>Excelent article!But I&#039;m having trouble using DataAccessController, cant&#039; find it anywere...
Please advise where to find this utility class./Kent</description> <content:encoded><![CDATA[<p>Excelent article!</p><p>But I&#8217;m having trouble using DataAccessController, cant&#8217; find it anywere&#8230;<br
/> Please advise where to find this utility class.</p><p>/Kent</p> ]]></content:encoded> </item> <item><title>By: Jason Lee</title><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/comment-page-1/#comment-8560</link> <dc:creator>Jason Lee</dc:creator> <pubDate>Tue, 26 Jan 2010 20:51:55 +0000</pubDate> <guid
isPermaLink="false">http://blogs.steeplesoft.com/?p=520#comment-8560</guid> <description>Paul, well, I&#039;m sorry to disappoint you.  Personally, I think the use case you describe is pretty simple.  From the hip, two solutions come to mind.  Both would use setTimeOut().  One solution would be to programmatically click a possibly hidden h:commandButton with a nested f:ajax that refreshes the table.  The other solution would call jsf.ajax.request directly to refresh the table.There may be more elegant solutions using the standard components and JS libraries, and there&#039;s certainly third party solutions like a4j:poll, but the above should get you heading in the right direction.</description> <content:encoded><![CDATA[<p>Paul, well, I&#8217;m sorry to disappoint you.  Personally, I think the use case you describe is pretty simple.  From the hip, two solutions come to mind.  Both would use setTimeOut().  One solution would be to programmatically click a possibly hidden h:commandButton with a nested f:ajax that refreshes the table.  The other solution would call jsf.ajax.request directly to refresh the table.</p><p>There may be more elegant solutions using the standard components and JS libraries, and there&#8217;s certainly third party solutions like a4j:poll, but the above should get you heading in the right direction.</p> ]]></content:encoded> </item> <item><title>By: paul cunningham</title><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/comment-page-1/#comment-8559</link> <dc:creator>paul cunningham</dc:creator> <pubDate>Tue, 26 Jan 2010 10:33:55 +0000</pubDate> <guid
isPermaLink="false">http://blogs.steeplesoft.com/?p=520#comment-8559</guid> <description>I read this expecting to be shown how to refresh a table at intervals with f:ajax.I thought this would be the most obvious example of the use of ajax with with data tables as it is a common desire to display up to date data.previously i used a4jsf:pollit amazes me how people who write articles and manuals seem to be  always on a different wavelength</description> <content:encoded><![CDATA[<p>I read this expecting to be shown how to refresh a table at intervals with f:ajax.</p><p>I thought this would be the most obvious example of the use of ajax with with data tables as it is a common desire to display up to date data.</p><p>previously i used a4jsf:poll</p><p>it amazes me how people who write articles and manuals seem to be  always on a different wavelength</p> ]]></content:encoded> </item> <item><title>By: Alberto Gori</title><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/comment-page-1/#comment-8538</link> <dc:creator>Alberto Gori</dc:creator> <pubDate>Mon, 21 Dec 2009 09:12:09 +0000</pubDate> <guid
isPermaLink="false">http://blogs.steeplesoft.com/?p=520#comment-8538</guid> <description>@bhavinIt&#039;s solved if you use the ViewScope.</description> <content:encoded><![CDATA[<p>@bhavin</p><p>It&#8217;s solved if you use the ViewScope.</p> ]]></content:encoded> </item> <item><title>By: Rrz</title><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/comment-page-1/#comment-8530</link> <dc:creator>Rrz</dc:creator> <pubDate>Mon, 14 Dec 2009 19:50:58 +0000</pubDate> <guid
isPermaLink="false">http://blogs.steeplesoft.com/?p=520#comment-8530</guid> <description>Would you please provide more info on DataAccessController? I am trying to learn JSF 2.0 datatable. But without knowing how to get DataAccessController, I am stucked.</description> <content:encoded><![CDATA[<p>Would you please provide more info on DataAccessController? I am trying to learn JSF 2.0 datatable. But without knowing how to get DataAccessController, I am stucked.</p> ]]></content:encoded> </item> <item><title>By: bhavin</title><link>http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/comment-page-1/#comment-8524</link> <dc:creator>bhavin</dc:creator> <pubDate>Fri, 13 Nov 2009 03:09:07 +0000</pubDate> <guid
isPermaLink="false">http://blogs.steeplesoft.com/?p=520#comment-8524</guid> <description>what about the command links if the bean is request scoped. Is there something solved in 2.0.I just tried and still the action is not hit.
Please advice</description> <content:encoded><![CDATA[<p>what about the command links if the bean is request scoped. Is there something solved in 2.0.I just tried and still the action is not hit.<br
/> Please advice</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching using disk: basic

Served from: blogs.steeplesoft.com @ 2012-02-07 14:46:28 -->
