Author: SeanRogers
Date: 2009-12-21 01:48:31 -0500 (Mon, 21 Dec 2009)
New Revision: 16174
Added:
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-1.js
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-2.xml_sample
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-0.js
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-1.js
root/docs/trunk/Component_Reference/en-US/images/figu-Component_Reference-Resources-a4jmediaOutput_example_result.png
Modified:
root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Resources.xml
Log:
Finished resources
Modified:
root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Resources.xml
===================================================================
---
root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Resources.xml 2009-12-18
19:38:13 UTC (rev 16173)
+++
root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Resources.xml 2009-12-21
06:48:31 UTC (rev 16174)
@@ -111,8 +111,14 @@
The <sgmltag><a4j:loadScript></sgmltag> component allows
scripts to be loaded from external sources such as <filename>jar</filename>
files.
</para>
<para>
- The required <varname>src</varname> attribute defines the path to the
script. A leading slash (<literal>/</literal>) represents the root of the web
context. The <code>resource:///</code> prefix can be used to access a file in
the RichFaces resource framework.
+ The required <varname>src</varname> attribute defines the path to the
script. A leading slash (<literal>/</literal>) represents the root of the web
context. The <code>resource://</code> prefix can be used to access a file in
the RichFaces resource framework. The path is passed to the
<methodname>getResourceURL()</methodname> method of the application's
<classname>ViewHandler</classname>, with the result then being passed through
the <methodname>encodeResourceURL()</methodname> method of
<classname>ExternalContext</classname>.
</para>
+ <example
id="exam-Component_Reference-Resources-a4jloadScript_example">
+ <title><sgmltag><a4j:loadScript></sgmltag>
example</title>
+<programlisting language="XML" role="XML">
+<a4j:loadScript src="resource:///org/mycompany/assets/script/focus.js"
/>
+</programlisting>
+ </example>
</section>
<section id="sect-Component_Reference-Resources-a4jloadStyle">
@@ -120,28 +126,37 @@
<itemizedlist>
<listitem>
<para>
- component-type: <classname>org.ajax4jsf.Push</classname>
+ component-type: <classname>org.ajax4jsf.LoadStyle</classname>
</para>
</listitem>
<listitem>
<para>
- component-family:
<classname>org.ajax4jsf.components.AjaxPush</classname>
+ component-family: <classname>org.ajax4jsf.LoadStyle</classname>
</para>
</listitem>
<listitem>
<para>
- component-class:
<classname>org.ajax4jsf.component.html.AjaxPush</classname>
+ component-class:
<classname>org.ajax4jsf.component.html.HtmlLoadStyle</classname>
</para>
</listitem>
<listitem>
<para>
- renderer-type:
<classname>org.ajax4jsf.components.AjaxPushRenderer</classname>
+ renderer-type: <classname>org.ajax4jsf.LoadStyleRenderer</classname>
</para>
</listitem>
</itemizedlist>
<para>
- Incomplete
+ The <sgmltag><a4j:loadStyle></sgmltag> component allows a
style sheet to be loaded from an external source, such as a
<filename>jar</filename> file. The style sheet links are inserted into the
head element.
</para>
+ <para>
+ The required <varname>src</varname> attribute defines the path to the
script. A leading slash (<literal>/</literal>) represents the root of the web
context. The <code>resource://</code> prefix can be used to access a file in
the RichFaces resource framework. The path is passed to the
<methodname>getResourceURL()</methodname> method of the application's
<classname>ViewHandler</classname>, with the result then being passed through
the <methodname>encodeResourceURL()</methodname> method of
<classname>ExternalContext</classname>.
+ </para>
+ <example id="exam-Component_Reference-Resources-a4jloadStyle_example">
+ <title><sgmltag><a4j:loadStyle></sgmltag>
example</title>
+<programlisting language="XML" role="XML">
+<a4j:loadStyle src="resource:///org/mycompany/assets/script/focus.js"
/>
+</programlisting>
+ </example>
</section>
<section id="sect-Component_Reference-Resources-a4jkeepAlive">
@@ -149,28 +164,35 @@
<itemizedlist>
<listitem>
<para>
- component-type: <classname>org.ajax4jsf.Push</classname>
+ component-type:
<classname>org.ajax4jsf.components.KeepAlive</classname>
</para>
</listitem>
<listitem>
<para>
- component-family:
<classname>org.ajax4jsf.components.AjaxPush</classname>
+ component-family:
<classname>org.ajax4jsf.components.AjaxKeepAlive</classname>
</para>
</listitem>
<listitem>
<para>
- component-class:
<classname>org.ajax4jsf.component.html.AjaxPush</classname>
+ component-class:
<classname>org.ajax4jsf.components.AjaxKeepAlive</classname>
</para>
</listitem>
- <listitem>
- <para>
- renderer-type:
<classname>org.ajax4jsf.components.AjaxPushRenderer</classname>
- </para>
- </listitem>
</itemizedlist>
<para>
- Incomplete
+ The <sgmltag><a4j:keepAlive></sgmltag> component allows the
state of a managed bean to be retained between Ajax requests.
</para>
+ <para>
+ Managed beans can be declared with the <literal>request</literal> scope in
the <filename>faces-config.xml</filename> configuration file, using the
<sgmltag><managed-bean-scope></sgmltag> tag. Any references to
the bean instance after the request has ended will cause the server to throw an illegal
argument exception. The <sgmltag><a4j:keepAlive></sgmltag>
component avoids this be maintaining the state of the whole bean object for subsequent
requests.
+ </para>
+ <para>
+ The <varname>beanName</varname> attribute uses JSF Expression Language
(<acronym>EL</acronym>) to define the request scope bean name to keep alive.
The expression must resolve to a managed bean instance. The
<varname>ajaxOnly</varname> attribute determines whether or not the value of
the bean should be available during non-Ajaxx requests; if
<code>ajaxOnly="true"</code>, the request-scope bean keeps its value
during Ajax requests, but any non-Ajax requests will re-create the bean as a regular
request-scope bean.
+ </para>
+ <example id="exam-Component_Reference-Resources-a4jkeepAlive_example">
+ <title><sgmltag><a4j:keepAlive></sgmltag>
example</title>
+<programlisting language="XML" role="XML">
+<a4j:keepAlive beanName="#{myClass.testBean}" />
+</programlisting>
+ </example>
</section>
<section id="sect-Component_Reference-Resources-a4jmediaOutput">
@@ -198,8 +220,89 @@
</listitem>
</itemizedlist>
<para>
- Incomplete
+ The <sgmltag><a4j:mediaOutput></sgmltag> component is used
for generating images, video, sounds, and other resources defined on the fly.
</para>
+ <para>
+ The <varname>createContent</varname> attribute points to the method used
for generating the displayed content. If necessary, the
<varname>value</varname> attribute can be used to pass input data to the
content generation method specified with <varname>createContent</varname>. The
<varname>cacheable</varname> attribute specifies whether the resulting content
will be cached or not.
+ </para>
+ <para>
+ The <varname>mimeType</varname> attribute describes the type of output
content, and corresponds to the type in the header of the
<acronym>HTTP</acronym> request. The <varname>element</varname>
attribute defines <attribute>XHTML</attribute> element used to display the
content:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>img</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>object</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>applet</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>script</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>link</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>a</literal>
+ </para>
+ </listitem>
+ </itemizedlist>
+ <example
id="exam-Component_Reference-Resources-a4jmediaOutput_example">
+ <title><sgmltag><a4j:mediaOutput></sgmltag>
example</title>
+ <para>
+ This example uses the <sgmltag><a4j:mediaOutput></sgmltag>
component to generate a <acronym>JPEG</acronym> image of verification digits.
The code on the application page is a single element:
+ </para>
+<programlisting language="XML" role="XML">
+<a4j:mediaOutput element="img" cacheable="false"
session="false" createContent="#{mediaBean.paint}"
value="#{mediaData}" mimeType="image/jpeg" />
+</programlisting>
+ <para>
+ The <sgmltag><a4j:mediaOutput></sgmltag> component uses the
<methodname>MediaBean.paint</methodname> method to create the image. The
method generates a random number, which is then converted into an output stream and
rendered to a <acronym>JPEG</acronym> image. The
<classname>MediaBean</classname> class is as follows:
+ </para>
+<programlisting language="XML" role="XML">
+<xi:include parse="text"
href="extras/exam-Component_Reference-Resources-a4jmediaOutput_example-0.js"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+</programlisting>
+ <para>
+ Another class, <classname>MediaData</classname> is required by the
<varname>value</varname> attribute for keeping data to be used as input for
the content creation method. The <classname>MediaData</classname> class is as
follows:
+ </para>
+<programlisting language="XML" role="XML">
+<xi:include parse="text"
href="extras/exam-Component_Reference-Resources-a4jmediaOutput_example-1.js"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+</programlisting>
+ </example>
+ <note>
+ <title>Note</title>
+ <para>
+ A bean class passed using the <varname>value</varname> attribute of
<sgmltag><a4j:mediaOutput></sgmltag> should implement the
<classname>Serializable</classname> interface so that it will be encoded to
the <acronym>URL</acronym> of the resource.
+ </para>
+ </note>
+ <para>
+ The <sgmltag><a4j:mediaOutput></sgmltag> component uses the
<classname>MediaBean</classname> and
<classname>MediaData</classname> classes to generate a new image on each page
refresh, which appears as
+ </para>
+ <figure
id="figu-Component_Reference-Resources-a4jmediaOutput_example_result">
+ <title><sgmltag><a4j:mediaOutput></sgmltag> example
result</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata
fileref="images/figu-Component_Reference-Resources-a4jmediaOutput_example_result.png"
format="PNG" />
+ </imageobject>
+ <textobject>
+ <para>
+ The generated image containing a random verification number.
+ </para>
+ </textobject>
+ </mediaobject>
+ </figure>
</section>
</chapter>
Added:
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-1.js
===================================================================
---
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-1.js
(rev 0)
+++
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-1.js 2009-12-21
06:48:31 UTC (rev 16174)
@@ -0,0 +1,44 @@
+package demo;
+
+
+ import java.util.Locale;
+
+ import javax.faces.context.FacesContext;
+
+
+ public class ChangeLocale {
+
+ public String germanAction() {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ context.getViewRoot().setLocale(Locale.GERMAN);
+
+ return null;
+
+ }
+
+
+ public String englishAction() {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ context.getViewRoot().setLocale(Locale.ENGLISH);
+
+ return null;
+
+ }
+
+
+
+ public String italianAction() {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ context.getViewRoot().setLocale(Locale.ITALIAN);
+
+ return null;
+
+ }
+
+}
Added:
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-2.xml_sample
===================================================================
---
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-2.xml_sample
(rev 0)
+++
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jloadBundle-2.xml_sample 2009-12-21
06:48:31 UTC (rev 16174)
@@ -0,0 +1,8 @@
+<h:form>
+ <a4j:loadBundle var="msg" basename="demo.message"/>
+ <h:outputText id="messageBundle" value="#{msg.greeting}"/>
+ <a4j:commandLink value="De" action="#{changeLocale.germanAction}"
reRender="messageBundle" />
+ <a4j:commandLink value="Eng"
action="#{changeLocale.englishAction}" reRender="messageBundle" />
+ <a4j:commandLink value="It"
action="#{changeLocale.italianAction}" reRender="messageBundle" />
+</h:form>
+
Added:
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-0.js
===================================================================
---
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-0.js
(rev 0)
+++
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-0.js 2009-12-21
06:48:31 UTC (rev 16174)
@@ -0,0 +1,31 @@
+package demo;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Random;
+import javax.imageio.ImageIO;
+
+public class MediaBean {
+
+ public void paint(OutputStream out, Object data) throws IOException {
+
+ Integer high = 9999;
+ Integer low = 1000;
+ Random generator = new Random();
+ Integer digits = generator.nextInt(high - low + 1) + low;
+
+ if (data instanceof MediaData) {
+ MediaData paintData = (MediaData) data;
+ BufferedImage img = new
BufferedImage(paintData.getWidth(),paintData.getHeight(),BufferedImage.TYPE_INT_RGB);
+ Graphics2D graphics2D = img.createGraphics();
+ graphics2D.setBackground(paintData.getBackground());
+ graphics2D.setColor(paintData.getDrawColor());
+ graphics2D.clearRect(0,0,paintData.getWidth(),paintData.getHeight());
+ graphics2D.setFont(paintData.getFont());
+ graphics2D.drawString(digits.toString(), 20, 35);
+ ImageIO.write(img,"png",out);
+ }
+ }
+}
Added:
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-1.js
===================================================================
---
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-1.js
(rev 0)
+++
root/docs/trunk/Component_Reference/en-US/extras/exam-Component_Reference-Resources-a4jmediaOutput_example-1.js 2009-12-21
06:48:31 UTC (rev 16174)
@@ -0,0 +1,22 @@
+package demo;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.io.Serializable;
+
+public class MediaData implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ Integer Width=110;
+ Integer Height=50;
+
+ Color Background=new Color(190, 214, 248);
+ Color DrawColor=new Color(0,0,0);
+
+ Font font = new Font("Serif", Font.TRUETYPE_FONT, 30);
+
+ /* Corresponding getters and setters */
+ ...
+
+}
Added:
root/docs/trunk/Component_Reference/en-US/images/figu-Component_Reference-Resources-a4jmediaOutput_example_result.png
===================================================================
(Binary files differ)
Property changes on:
root/docs/trunk/Component_Reference/en-US/images/figu-Component_Reference-Resources-a4jmediaOutput_example_result.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream