<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
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/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>OcpSoft &#187; Ajax4Jsf</title> <atom:link href="http://ocpsoft.com/tags/ajax4jsf/feed/" rel="self" type="application/rss+xml" /><link>http://ocpsoft.com</link> <description>&#34;Simple Software&#34;</description> <lastBuildDate>Tue, 27 Jul 2010 15:07:50 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0</generator> <item><title>Ajax4Jsf &lt;a4j:form data=&#8221;broken!&#8221;&gt;</title><link>http://ocpsoft.com/opensource/ajax4jsf-a4jform-databroken/</link> <comments>http://ocpsoft.com/opensource/ajax4jsf-a4jform-databroken/#comments</comments> <pubDate>Mon, 25 Aug 2008 05:31:50 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[JSF]]></category> <category><![CDATA[OpenSource]]></category> <category><![CDATA[Ajax4Jsf]]></category> <category><![CDATA[Java]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=9</guid> <description><![CDATA[A4J:Form is missing several specified ajax functions (View this issue on the JBoss tracker here. Keep reading, there is a fix&#8230; download fix) The issue: When using the a4j:form component, the data=&#8221;#{managedBean.property}&#8221; the properties defined in the data element list are supposed to be available after the a4j event in the data JavaScript variable; however, [...]]]></description> <content:encoded><![CDATA[<h2>A4J:Form is missing several specified ajax functions</h2><p>(<em>View this issue on the JBoss tracker <a
href="https://jira.jboss.org/jira/browse/AJSF-141" target="_blank">here</a>. Keep reading, there is a fix&#8230;<a
href="https://jira.jboss.org/jira/secure/attachment/12321714/UIAjaxForm.java"> download fix</a></em>)</p><h3>The issue:</h3><p>When using the a4j:form component, the <em>data=&#8221;#{managedBean.property}&#8221;</em> the properties defined in the <em>data</em> element list are supposed to be available after the a4j event in the <em>data</em> JavaScript variable; however, with &lt;a4j:form&gt; the attribute is not correctly causing the JavaScript <em>data</em> variable to be populated.<br
/> <span
id="more-9"></span><br
/> The <em>data</em> variable is always undefined, even if the managed bean property is set to a valid value. This is exhibited by the alert box as the value is displayed, &#8220;(undefined)&#8221;.</p><h4>Example:</h4><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;">&nbsp;</pre></div></div><p
style="text-align: center;">&#8212;-</p><h3>The workaround:</h3><p>Taking a look at the source code revealed that the &lt;a4j:form&gt; was not in fact including this behavior at all in the <em>broadcast()</em> method, which is where the <em>data</em> element processing occurs in the &lt;a4j:commandButton&gt;.</p><h4>UIAjaxForm.broadcast()</h4><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">/* (non-Javadoc)
     * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
     */</span>
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> broadcast<span style="color: #009900;">&#40;</span>FacesEvent event<span style="color: #009900;">&#41;</span>
               <span style="color: #000000; font-weight: bold;">throws</span> AbortProcessingException <span style="color: #009900;">&#123;</span>
          <span style="color: #666666; font-style: italic;">// perform default</span>
          <span style="color: #000000; font-weight: bold;">super</span> .<span style="color: #006633;">broadcast</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event <span style="color: #000000; font-weight: bold;">instanceof</span>  AjaxEvent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #666666; font-style: italic;">// complete re-Render fields. AjaxEvent deliver before render response.</span>
               setupReRender<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#125;</span></pre></div></div><p
style="text-align: center;">&#8212;-</p><p>In fact, however, if we modify the &lt;a4j:form&gt; <em>broadcast()</em> method to behave like its &lt;a4j:commandButton&gt; relative, we can still achieve this functionality!</p><h4>Updated: UIAjaxForm.broadcast()</h4><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> broadcast<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> FacesEvent event<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> AbortProcessingException
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">broadcast</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event <span style="color: #000000; font-weight: bold;">instanceof</span> AjaxEvent<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setupReRender</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">Object</span> data <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            AjaxContext ajaxContext <span style="color: #339933;">=</span> AjaxContext.<span style="color: #006633;">getCurrentInstance</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">!=</span> data<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                ajaxContext.<span style="color: #006633;">setResponseData</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #003399;">String</span> focus <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getFocus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">!=</span> focus<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                UIComponent focusComponent <span style="color: #339933;">=</span> RendererUtils.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">findComponentFor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, focus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">!=</span> focusComponent<span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
                    focus <span style="color: #339933;">=</span> focusComponent.<span style="color: #006633;">getClientId</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                ajaxContext.<span style="color: #006633;">getResponseDataMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>AjaxActionComponent.<span style="color: #006633;">FOCUS_DATA_ID</span>, focus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            ajaxContext.<span style="color: #006633;">setOncomplete</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getOncomplete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div><p
style="text-align: center;">&#8212;-</p><p>We&#8217;re set!</p><p>I don&#8217;t particularly like to repeat this code, so I may get around to refactoring everything and submitting it back to the Ajax4JSF project. For now, though, this blog will have to do.</p><p>I believe other functionality that was also broken included both the <em>focus=&#8221;elementId&#8221;</em> and the <em>oncomplete=&#8221;javascriptCode&#8221;</em>.</p><p>As always, please feel free to improve and comment on this. Enjoy!</p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/opensource/ajax4jsf-a4jform-databroken/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Served from: ocpsoft.com @ 2010-07-29 17:05:16 by W3 Total Cache -->