<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Roger Kitain&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/" />
<modified>2008-09-15T14:41:20Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/rogerk/252</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, rogerk</copyright>
<entry>
<title>JavaServer Faces 2.0 Early Draft Review 2 And JavaScript?</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2008/09/javaserver_face.html" />
<modified>2008-09-15T14:41:20Z</modified>
<issued>2008-09-15T14:41:20Z</issued>
<id>tag:weblogs.java.net,2008:/blog/rogerk/252.10453</id>
<created>2008-09-15T14:41:20Z</created>
<summary type="text/plain">The second Early Draft Review of the JavaServer Faces 2.0 specification was released to the Java Community Process (JCP)  and with it went a JavaScript public API.</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[<p>
The JavaScript public API is the beginnings of the client side portion of
the JavaServer Faces / Ajax standard.  The JavaServer Faces 2.0 Expert Group includes members representing other JavaServer Faces / Ajax frameworks such as RichFaces, ADF Faces (Trinidad) and ICEfaces.
</p>        
<p>
We're definitely exploring new territory here, as this is the first time
that a public JavaScript API has been introduced with JavaServer Faces to  the JCP.  It may be the first time a public JavaScript API has been 
introduced to the JCP, period.</p>]]>

</content>
</entry>
<entry>
<title>Back To Basics With JSF and Ajax</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2007/07/back_to_basics.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-07-31T03:27:38Z</issued>
<id>tag:weblogs.java.net,2007:/blog/rogerk/252.7941</id>
<created>2007-07-31T03:27:38Z</created>
<summary type="text/plain">This past week I had the pleasure of attending (and presenting at) the Ajax Experience in San Francisco.  The collection of talks were good and the &quot;Reverse Ajax&quot; (Comet) talks were particularly interesting.  I spoke a bit about JSF and Ajax, and I&apos;d like to share the technical details of a little &quot;mashup&quot; I put together for my talk.</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[This demo uses the Dynamic Faces library (with JSF) to illustrate a stock lookup service.  To simplify things for the demo, there are only three artifacts used in the demo:
<ol>
<li>One JSP page</li>
<li>One small JavaScript file</li>
<li>One Managed Bean</li>
</ol>
First, let's take a look at the UI:
<table ools="1" border="1">
<tr>
<td>
<img alt="stock-faces-ui.GIF" src="http://weblogs.java.net/blog/rogerk/archive/stock-faces-ui.GIF" width="805" height="450" />
</td>
</tr>
</table>
<br>
The UI is pretty basic.  You enter one or more space delimited stock symbols in the "Symbols" text field and press the "Search" button.  You can enter proxy information if you are behind a firewall.  The most interesting feature of the demo is the "Streaming" option.  If "Streaming" is set to "On", the client will poll the server, firing Ajax transactions every 10 seconds (or a specified time interval).  The "Remote/Local" option allows you to switch the demo to use local data, if a network connection is not available.  If the "Remote" option is used, the <b>Yahoo Stock Quoting</b> service is used to get the stock data.  The table of stock data will dynamically change size depending on the number of symbols that are used in the query.  Let's take a look at the artifacts used in this demo.
<br><br>
<b>JSP</b>
<br>
<br>
Here's a snippet of the JSP page for the demo, showing the relevant parts:
<br>
<br>
<table style="width: 100%; background-color: rgb(0, 0, 0); text-align: left;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="background-color: rgb(255, 255, 204); vertical-align: top;">&lt;f:view&gt;<br>
&lt;html&gt;<br>
&lt;head&gt;<br>
...<br>
...<br>
<span style="color: rgb(51, 51, 255);">&lt;jsfExt:scripts/&gt;</span><br>
&lt;script type="text/javascript"&gt;<br>
...<br>
...<br>
<span style="color: rgb(51, 51, 255);">include_js('javascripts/stock-faces.js');</span><br>
&lt;/script&gt;<br>
&lt;/head&gt;<br>
&lt;body&gt;<br>
&nbsp; &lt;h:form id="form" prependId="false"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;h:panelGrid styleClass="title-panel"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Stock Query" styleClass="title-panel-text"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText
value="Powered By Dynamic Faces" styleClass="title-panel-subtext"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;h:panelGrid border="1" columns="1" styleClass="panel-input-border"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid border="1" columns="7"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Symbol:"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:inputText id="symbol"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 51, 255);">&lt;h:commandButton id="search" value="Search" </span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
onclick="DynaFaces.fireAjaxTransaction(this, {});return false;"</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
actionListener="#{bean.getStockInfo}" /&gt;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Proxy Host:"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:inputText id="proxyHost"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Proxy Port:"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:inputText id="proxyPort"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Streaming:"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 51, 255);">&lt;h:selectOneMenu id="streaming" value="Off" </span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; onchange="toggleStreaming()"&gt;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;f:selectItem itemValue="Off" itemLabel="Off"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;f:selectItem itemValue="On" itemLabel="On"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:selectOneMenu&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:selectOneMenu id="connection" value="Local"&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;f:selectItem itemValue="Local" itemLabel="Local"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;f:selectItem itemValue="Remote" itemLabel="Remote"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:selectOneMenu&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 51, 255);">&lt;h:panelGrid id="stockdata" border="1" columns="8"</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; styleClass="panel-data-border" rendered="false"&gt;</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Symbol"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Name"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Open"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Last"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value=""/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Change"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;h:outputText value="Change %"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText value="Volume"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/h:panelGrid&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp; &lt;/h:form&gt;<br>
&lt;/body&gt;<br>
&lt;/html&gt;<br>
&lt;/f:view&gt;<br>
</td>
</tr>
</tbody>
</table>
<br>
Here is an explanation of the "blue" sections in the code snippet:
<ol>
<li>
<i>&lt;jsfExt:scripts/&gt;</i> is the standard tag to include for Dynamic Faces applications, and it includes the Dynamic Faces JavaScript library.
</li>
<li>
The <i>include_js('javascripts/stock-faces.js');</i> line is just a utility function that loads the application's JavaScript file <i>stock-faces.js</i> (which we will discuss next).
</li>
<li>
The <i>h:commandButton</i> tag has an <i>onclick</i> JavaScript event handler attached to it - <i>DynaFaces.fireAjaxTransaction</i>, which will send an Ajax request to the server when the button is pressed.  The <i>actionListener</i> specified by <i>#{bean.getStockInfo}</i> will get executed on the server as usual.  But the key is that any view or JSF component manipulation done on the server will happen over Ajax.
</li>
<li>
The "streaming" option is just a <i>h:selectOneMenu</i> component that has an <i>onchange</i> JavaScript event handler.
</li>
<li>
Next is the "placeholder" for our dynamic table of stock data.  The attribute <i>rendered</i> is set to <i>false</i>, but this will be set to true from the application code when there is stock data to return.
</li>
</ol>
Get the entire source of this file <a href="http://weblogs.java.net/blog/rogerk/archive/home.jsp">here</a>.
<br>
<br>
<b>Application JavaScript</b>
<br>
<br>
stock-faces.js
<table style="width: 100%; background-color: rgb(0, 0, 0); text-align: left;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="background-color: rgb(255, 255, 204); vertical-align: top;">var pollId;<br>
<br>
/** Delay between requests to the server when polling. */<br>
var pollDelay = 10000;<br>
<br>
/** Start polling the server */<br>
function start() {<br>
&nbsp;&nbsp;&nbsp; pollId = setInterval(poll, pollDelay);<br>
}<br>
<br>
/** Stop polling the server */<br>
function stop() {<br>
&nbsp;&nbsp;&nbsp; clearInterval(pollId);<br>
}<br>
<br>
function poll() {<br>
&nbsp;&nbsp;&nbsp; queueEvent();<br>
&nbsp;&nbsp;&nbsp; DynaFaces.fireAjaxTransaction(null, {});<br>
}<br>
<br>
function queueEvent() {<br>
&nbsp;&nbsp;&nbsp; var actionEvent =<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new DynaFaces.ActionEvent("search",<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DynaFaces.PhaseId.INVOKE_APPLICATION);<br>
&nbsp;&nbsp;&nbsp; DynaFaces.queueFacesEvent(actionEvent);<br>
&nbsp;&nbsp;&nbsp; return false;<br>
}<br>
<br>
function toggleStreaming() {<br>
&nbsp;&nbsp;&nbsp; var menu = document.getElementById("streaming");<br>
&nbsp;&nbsp;&nbsp; var idx = menu.selectedIndex;<br>
&nbsp;&nbsp;&nbsp; var streaming = menu[idx].value;<br>
&nbsp;&nbsp;&nbsp; if (streaming == "Off") {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stop();<br>
&nbsp;&nbsp;&nbsp; } else if (streaming == "On") {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start();<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
</td>
</tr>
</tbody>
</table>
<br>
<ol>
<li>
The polling delay (or the time interval between calls to the server is  10 seconds.
</li>
<li>
The <i>start()</i> function kicks off the server polling.
</li>
<li>
The <i>stop()</i> function stops server polling.
</li>
<li>
The <i>poll()</i> function does two things:
<ol>
<li>
It queues up a server side <i>JSF action event</i>.
<li>
<li>
Fires an Ajax request to the server using the Dynamic Faces library.
</li>
</ol>
</li>
<li>
The <i>queueEvent()</i> function queues up a server side <>JSF action event</i> using the Dynamic Faces library.  This action event will get processed during the standard JSF lifecycle processing as the Ajax request flows through.
</li>
<li>The <i>toggleStreaming()</i> function just toggles the value of the "streaming" menu control.
</li>
</ol>
Get the entire source for this file <a href="http://weblogs.java.net/blog/rogerk/archive/stock-faces.js">here</a>.
<br>
<br>
<b>JSF Managed Bean</b>
<br>
<br>
Bean.java (how original...)
<table style="width: 100%; background-color: rgb(0, 0, 0); text-align: left;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="background-color: rgb(255, 255, 204); vertical-align: top;">/**<br>
&nbsp;* This bean has methods to retrieve stock information from<br>
&nbsp;* the Yahoo quote service.<br>
&nbsp;*/<br>
<span style="color: rgb(0, 153, 0);">public class Bean {</span><br>
<br>
&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">private static final String SERVICE_URL =</span><br style="color: rgb(0, 153, 0);">
<span style="color: rgb(0, 153, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "http://quote.yahoo.com/d/quotes.csv";</span><br>
<br>
&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp;&nbsp; * Action method that is used to retrieve stock information.<br>
&nbsp;&nbsp;&nbsp;&nbsp; * This method uses two helper methods - one to get the<br>
&nbsp;&nbsp;&nbsp;&nbsp; * stock information, and the other to dynamically build<br>
&nbsp;&nbsp;&nbsp;&nbsp; * the "data" components for the UI.<br>
&nbsp;&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">public void getStockInfo(ActionEvent ae) {</span><br>
...<br>
...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style="color: rgb(0, 153, 0);">stockData = getStockData(symbols);</span><br style="color: rgb(0, 153, 0);">
<span style="color: rgb(0, 153, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
buildUI(stockData);</span><br>
...<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp;&nbsp; * Helper method to get the stock data (remotely).<br>
&nbsp;&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 153, 0);">private</span> <span style="color: rgb(0, 153, 0);">String[]</span> <span style="color: rgb(0, 153, 0);">getStockData(String[] symbols)</span></span><br style="color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throws IOException, MalformedURLException {</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">String[] data = new String[symbols.length];</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i=0; i&lt;symbols.length; i++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuffer sb = new StringBuffer(SERVICE_URL);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb.append("?s=");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb.append(symbols[i]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb.append("&amp;f=snol1cp2v=.csv");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String url = sb.toString();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; URLConnection urlConn = null;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputStreamReader inputReader = null;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BufferedReader buff = null;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
urlConn = new URL(url).openConnection();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inputReader = new InputStreamReader(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
urlConn.getInputStream());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
buff = new BufferedReader(inputReader);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data[i] = buff.readLine();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
data[i] = data[i].replace( "\"", "" );<br>
...<br>
...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">return data;</span><br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp;&nbsp; * Helper method to dynamically add JSF components to display<br>
&nbsp;&nbsp;&nbsp;&nbsp; * the data.<br>
&nbsp;&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; private <span style="color: rgb(0, 153, 0);">void buildUI(String[] stockData)</span> {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FacesContext context = FacesContext.getCurrentInstance();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UIForm form = (UIForm)context.getViewRoot().findComponent("form");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">UIPanel dataPanel = (UIPanel)form.findComponent("stockdata");</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String buffer = null;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataPanel.getChildren().clear();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i=0; i&lt;stockData.length; i++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] data = stockData[i].split("\\,");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UIOutput outputComponent = null;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UIGraphic imageComponent = null;<br>
...<br>
...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Create and add components wth data values<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Symbol<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputComponent = new UIOutput();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputComponent.setValue(data[0]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">dataPanel.getChildren().add(outputComponent);</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Name<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputComponent = new UIOutput();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputComponent.setValue(data[1]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">dataPanel.getChildren().add(outputComponent);</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Open Price (if any)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputComponent = new UIOutput();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
openPrice = new Double(data[2]).doubleValue();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (NumberFormatException nfe) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; openPriceAvailable = false;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputComponent.setValue(data[2]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">dataPanel.getChildren().add(outputComponent);</span><br>
...<br>
...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 153, 0);">dataPanel.setRendered(true);</span><br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
</td>
</tr>
</tbody>
</table>
<br>
This JSF Managed Bean has an action method <i>getStockInfo</i> that does two things:
<ol>
<li>
It uses a helper method <i>getStockData</i> to contact the Yahoo Stock Quote service (as defined by SERVICE_URL) to retrieve stock data for all the symbols.
</li>
<li>
It uses a helper method <i>buildUI</i> to build JSF components (from the stock data) and it adds the JSF components to the JSF component view.  After all components have been created and added, then it sets the <i>rendered</i> attribute to <i>true</i> on the "stockdata" JSF component.
</li>
</ol>
The action method, <i>getStockInfo</i> is called on two seperate occasions:
<ol>
<li>
It is called when the "Search" button is pressed.
</li>
<li>
It is also called as the result of an Ajax "poll" request.  This is because each client poll queues an action event tied to this event handler.  Refer to the <i>queueEvent</i> method in the <i>stock-faces.js</i> JavaScript file.
</li>
</ol>
Get the entire source of this file <a href="http://weblogs.java.net/blog/rogerk/archive/Bean.java">here</a>.
<br>
<br>
<b>Summary</b>
<br>
<br>
We've seen how we can combine the power of JSF component building with Ajax to produce dynamic applications.  This application illustrated the use of two features from Dynamic Faces:
<ol>
<li>
fireAjaxTransaction
</li>
<li>
Remote JSF event queueing from JavaScript
</li>
</ol>
This application is included as one of the samples applications in the  <a href="https://jsf-extensions.dev.java.net/">jsf-extensions</a> project.  Please refer to the <a href="http://wiki.java.net/bin/view/Projects/JsfExtensionsFaq">jsf-extensions FAQ</a> for getting and building the source code.
<br>
<br>
<b>Resources</b>
<br>
<br>
<a href="https://jsf-extensions.dev.java.net/">jsf-extensions</a><br>
<a href="https://glassfish.dev.java.net/">GlassFish</a><br>
<a href="https://javaserverfaces.dev.java.net/">javaserverfaces</a>

]]>

</content>
</entry>
<entry>
<title>MobileFaces, Mobile JSF Kit and GlassFish</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2007/06/mobilefaces_mob.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-06-28T22:06:15Z</issued>
<id>tag:weblogs.java.net,2007:/blog/rogerk/252.7749</id>
<created>2007-06-28T22:06:15Z</created>
<summary type="text/plain">Two weeks ago, Ericsson announced that MobileFaces, a core library based on the JSF architecture for extending web applications to mobile browsing devices, went open source.  The Mobile JSF Kit includes MobileFaces plus some sample applications to help you get started developing web applications for mobile devices.  GlassFish is a free, open source application server which implements the newest features in the Java EE 5 platform.  So, what do MobileFaces, Mobile JSF Kit and GlassFish all have in common?  They all work together...</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[The core MobileFaces library is currently based on the JSF 1.1 specification.  The library not only makes it easier to develop mobile web applications, but it also utilizes a key extensible piece of the JSF architecture - <strong>RenderKits</strong> and <strong>Renderers</strong>.  This allows the same underlying component model to render not only in HTML, but markup that is suitable for mobile devices (such as WML).  Here, we'll take a look at how we can get one of the sample Mobile JSF Kit applications up and running on the GlassFish application server.
<br/><br/>
<b>Prerequisites:</b>
<br/>
<ol>
  <li>A working build environment with <a href="http://ant.apache.org/">ant</a>,
at least <a href="http://java.sun.com/j2se/1.5.0/download.jsp">JDK 5</a>,
and <a href="https://glassfish.dev.java.net/public/downloadsindex.html#Official_supported_builds">GlassFish</a>. 
I've recently run MobileFaces and the Mobile JSF Kit on the <a href="https://glassfish.dev.java.net/downloads/v2-b52.html">GlassFish v2 B52 Promoted Build</a>.</li>
</ol>

<b>Setup:</b><br>
<ol>
<li>Download and unpack the <a href="http://www.ericsson.com/mobilityworld/sub/signup/login.html?oid=47623">Mobile Faces Source</a> to some directory, say <em>MobileFaces</em>.</li>
<li>Go to the MobileFaces directory.  Get the build.xml script and the associated build.properties file for GlassFish from <a href="http://weblogs.java.net/blog/rogerk/archive/build-mobilefaces-glassfish.zip">here</a> and unpack it in the MobileFaces directory.  Edit the <em>glassfish.home</em> property in the <em>build.properties.glassfish</em> file to refer to your GlassFish top level directory.</li>
<li>Build MobileFaces from source:  <em>ant -f build.xml.glassfish build</em></li>
<li>Download and unpack the <a href="http://www.ericsson.com/mobilityworld/sub/signup/login.html?oid=47223">Mobile JSF Kit</a>.  After you unpack it you will see a <em>samples</em> directory.</li>
<li>Go to the <strong>HelloMobile</strong> directory under the <em>samples</em> directry - this will be the sample application we'll be running.  Currently, the build scripts are set up to work with Tomcat.  Get the build.xml script and the associated build.properties file for GlassFish from <a href="http://weblogs.java.net/blog/rogerk/archive/build-mobilejsf-glassfish.zip">here</a> and unpack it in the HelloMobile directory.  Edit the <em>glassfish.home</em> property in the <em>build.properties.glassfish</em> file to refer to your GlassFish top level directory.  Edit the <em>mobilfaces.home</em> property in the <em>build.properties.glassfish</em> file to refer to your MobileFaces directory.</li>
<li>Build the HelloMobile application:  <em>ant -f build.xml.glassfish build</em></li>
<li>Start the GlassFish application server (if it's not already started) and deploy the application to the GlassFish application server.  The <em>helloMobile_R1A.war</em> file will be under the <em>HelloMobile/dist</em> directory.  The application will be deployed as: <strong>helloMobile_R1A</strong></li>
</ol>

<b>Running the Application:</b><br><br>

To test your mobile web application you can use a phone simulator with a mobile browser.  Here, we will use the Openwave Phone Simulator with the Openwave Mobile Browser.  The simulator uses the same browser that is embedded in real mobile phones.  I believe this simulator only works on Windows - but they may have a Linux version available as well.
<ol>
<li>Download and install the Openwave Phone Simulator from <a href="http://developer.openwave.com/dl/Openwave_v70_Simulator.exe">here</a>.</li>
<li> Start up the phone simulator.  In addition to the phone simulator you will see a console window for the simulator.</li>
<table ools="2" border="1">
<tr>
<td>
<img alt="phone-simulator.GIF" src="http://weblogs.java.net/blog/rogerk/archive/phone-simulator.GIF" width="170" height="450" />
</td>
<td>
<img alt="simulator-console.GIF" src="http://weblogs.java.net/blog/rogerk/archive/simulator-console.GIF" width="534" height="379" />
</td>
</tr>
</table>
</li>
<li>Configure the phone simulator to your environment.  Under <em>Settings</em> select <em>Server Profiles</em>.  There you can set your network settings.  I used <em>http-direct</em> with no proxy.</li>

<li>Configure the phone simulator with the appropriate <em>User-Agent</em>.  To test the WML rendering capabilities of MobileFaces, go to <em>Settings</em>, then <em>Device Settings</em>, and change the <em>User Agent</em> field to: <strong>OPWV-SDK-WML</strong>.</li>
<li>
Enter the URL <em>http://localhost:8080/helloMobile_R1A</em> in the phone simulator URL field and press "enter".</li>
</ol>
Now you should see the application loaded into the simulator.  You can also see the page content sent in the response in the simulator console window:
<table cols="2" border="1">
<tr>
<td>
<img alt="phone-simulator-1.GIF" src="http://weblogs.java.net/blog/rogerk/archive/phone-simulator-1.GIF" width="180" height="506" />
</td>
<td>
<img alt="simulator-console-1.GIF" src="http://weblogs.java.net/blog/rogerk/archive/simulator-console-1.GIF" width="562" height="450" />
</td>
</tr>
</table>

<br><b>Under The Hood:</b><br><br>
The MobileFaces architecture includes a servlet filter that examines the <em>user-agent</em> information on the incoming request.  The architecture also extends the JSF <strong>RenderKitFactory</strong> to load up RenderKits for xhtmL-MP and WML in addition to the Standard HTML RenderKit.  The extensibility of the JSF architecture allows you to create additional RenderKits.  Based on the <em>user-agent</em> it will create the appropriate <strong>RenderKit</strong> that will render the markup in the JSF <strong>Render Response Phase</strong>.  MobileFaces also includes a small library of custom tags to use in your pages and these can be used along with the Standard HTML JSF tags.

<br><br><b>Resources:</b><br><br>
<a href="https://glassfish.dev.java.net/">GlassFish Application Server</a><br>
<a href="http://www.ericsson.com/mobilityworld/sub/open/technologies/open_development_tips/tools/mobilefaces_src_code_lib">MobileFaces</a><br>
<a href="http://www.ericsson.com/mobilityworld/sub/open/technologies/open_development_tips/tools/mobile_jsf_kit">Mobile JSF Kit</a><br>
<a href="https://javaserverfaces.dev.java.net/">JavaServer Faces</a><br>
<br><br>
It's also worth noting that there is a Mobile JSF Kit Netbeans plugin available for download at the Mobile JSF site.  But that's a topic for discussion on another day..]]>

</content>
</entry>
<entry>
<title>Seam 1.1.0.GA On GlassFish</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2007/01/seam_110ga_on_g.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-01-04T18:12:26Z</issued>
<id>tag:weblogs.java.net,2007:/blog/rogerk/252.6257</id>
<created>2007-01-04T18:12:26Z</created>
<summary type="text/plain">Last month, another FCS release of Seam (1.1.0.GA) was released.
This release incorporates a number of great capabilities such as a RoR-like application generator called Seam-Gen.  I am happy to announce that this release of Seam runs on GlassFish with minimal setup.</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[To get prior releases of Seam running on GlassFish, you had to patch some Seam application modules.  With this release, there is no patchwork necessary - the folks at JBoss (RedHat) have done a great job of streamlining the process.  In fact, after you download and unpack the Seam 1.1.0.GA release from <a href="http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=163777&release_id=470955">here</a>,
you will see a GlassFish sample application (which is essentially the booking application) under the "jboss-seam-1.1.0.GA\examples\glassfish" directory.  In this entry, we will outline the steps to get this release of Seam running on GlassFish with Java Persistence.
<br/><br/>
<b>Prerequisites:</b>
<br/>
<ol>
  <li>A working build environment with <a href="http://ant.apache.org/">ant</a>,
at least <a href="http://java.sun.com/j2se/1.5.0/download.jsp">JDK 5</a>,
and <a href="https://glassfish.dev.java.net/public/downloadsindex.html#Official_supported_builds">GlassFish</a>.  I've run this version of Seam successfully on the <a href="https://glassfish.dev.java.net/downloads/v1_ur1-p01-b02.html">GlassFish v1 FCS (v1_ur1-p01-b02)</a> and <a href="https://glassfish.dev.java.net/downloads/v2-b30.html">GlassFish v2 (Build 30)</a> builds.</li>
</ol>


<b>Seam Setup:</b><br>
<ol>
<li>Download and install the Seam 1.1.0GA release from <a href="http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=163777&release_id=470955">here</a>.&nbsp;
You should see a jboss-seam-1.1.0.GA directory.</li>
<li>Go to the jboss-seam-1.1.0.GA/examples/glassfish directory.</li>
<li>Build the sample application using the "toplink" build target:
<ul><li>ant clean; ant toplink</li></ul>
The "toplink" target builds the EAR file using toplink as the JPA provider.  
</li>
</ol>
<b>Deploy the application:</b></br>
<ol>
<li>Start up GlassFish: &nbsp; <span style="font-style: italic;">&lt;glassfish
install dir&gt;</span>/bin/asadmin start-domain domain1</li>
<li>
Start the database:&nbsp; <span style="font-style: italic;">&lt;glassfish
install dir&gt;</span>/bin/asadmin
start-database</li>
<li>Deploy jboss-seam-1.1.0.GA/examples/glassfish/build/jboss-seam-glassfish.ear</li>
<ul><li>Note that deploying the application will create the necessary application database tables, and undeploying the application will remove the application database tables.</li></ul>
</ol>
<b>Load the database:</b><br>
<ol>
  <li>Get the sql script that will be used to load the database from 
<a href="http://weblogs.java.net/blog/rogerk/archive/import-sql.zip">here</a> and unpack it to some directory.  You should see the script: import.sql</li>
<li>Go to the directory that contains the <i>import.sql</i> script.</li>
<li>Set your CLASSPATH to include:
<ul>
<li><span style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derbyclient.jar</li>
<li><span style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derbytools.jar</li>
<li><span style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derby.jar</li>
</ul>
<li>Get into the "ij" utility:  java org.apache.derby.tools.ij</li>
<li>At the "ij>" prompt:
<ul>
<li>ij> DRIVER 'org.apache.derby.jdbc.ClientDriver';</li>
<li>ij> CONNECT 'jdbc:derby://localhost:1527/sun-appserv-samples';</li>
<li>ij> run 'import.sql';</li>
</ul>
</li>
</ol>
<ul>
  <li>Now the Seam application tables should be loaded.</li>
</ul>
<b>Run the application:</b><br>
<ul>
  <li>visit localhost:8080/jboss-seam-glassfish<br>
  </li>
</ul>]]>

</content>
</entry>
<entry>
<title>Seam (FCS) On GlassFish</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2006/07/seam_fcs_on_gla.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-07-25T18:45:27Z</issued>
<id>tag:weblogs.java.net,2006:/blog/rogerk/252.5245</id>
<created>2006-07-25T18:45:27Z</created>
<summary type="text/plain">My previous blog entries outlined some steps to get Seam running on GlassFish with Hibernate Persistence and Java Persistence.  The changes involved some modifications to the Seam core classes.  I am happy to report that JBoss has made the modifications in time for their Seam FCS release - so setup is even easier.  </summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[So far we've seen how we can get <a href="http://www.jboss.com/products/seam">Seam</a> running on <a href="https://glassfish.dev.java.net/">GlassFish</a> with Hibernate Persistence and Java Persistence.  Modifications were needed to the Seam core classes as well as the application classes.  Fortunately, JBoss has made the modifications to their core classes in time for their Seam FCS release.  In this entry we'll outline the steps to get the Seam FCS release up and running on GlassFish with Java Persistence.
<br/><br/>
<b>Prerequisites:</b>
<br/>
<ol>
  <li>A working build environment with <a href="http://ant.apache.org/">ant</a>,
at least <a href="http://java.sun.com/j2se/1.5.0/download.jsp">JDK 5</a>,
and <a href="https://glassfish.dev.java.net/public/downloadsindex.html#Official_supported_builds">GlassFish</a>
(build 43 or later).</li>
  <li>You'll need to use some of the Hibernate libraries that the Seam framework depends on:<br>
  </li>
  <ul>
    <li>Download and install <a
 href="http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=127784&amp;release_id=405151">Hibernate3
3.2cr1</a>.</li>
    <li>Download and install <a
 href="http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=156160&amp;release_id=405227">Hibernate
EntityManager 3.1 beta7</a>&nbsp;.&nbsp; Note that <span
 style="font-style: italic;">hibernate-entitymanager.jar</span> is not
required because we'll be using Java Persistence.&nbsp; However, <span
 style="font-style: italic;">hibernate-annotations.jar</span> is still
required, because the Seam framework uses classes from the Hibernate <span
 style="font-style: italic;">validator</span> package.<br>
    </li>
    <li>Copy the&nbsp;required hibernate jars into Glassfish lib dir.
The script <a
href="http://weblogs.java.net/blog/rogerk/archive/copyHibernateLibsJPersist.sh">here
      </a>contains the list of jars.</li>
    <li>Edit the script to make sure it references your Glassfish and
Hibernate install directories.</li>
    <li>Execute the script.<br>
    </li>
  </ul>
</ol>

<b>Seam Setup:</b><br>
<ol>
  <li>Download and install the Seam 1.0.1.GA release from <a
href="http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=163777&release_id=425718">here</a>.&nbsp;
You should see a jboss-seam-1.0.1.GA directory.</li>
  <li>Get the zip file: <a
href="http://weblogs.java.net/blog/rogerk/archive/seam-1.0.1.GA-booking-patch.zip">seam-1.0.1.GA-booking-patch.zip</a>
.&nbsp; <br>
  </li>
  <li>Go to the jboss-seam-1.0.1.GA directory and unzip
seam-1.0.1.GA-booking-patch.zip.</li>
</ol>
<b>Compilation Procedure:</b><br>
<ol>
<li>Copy jboss-seam-1.0.1.GA/lib/thirdparty-all.jar to <span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/lib&nbsp;</li>
<li>Compile Seam core classes - this will compile the HtmlLink class in the ui package.</li>
<ul>
<li>Go to the jboss-seam-1.0.1.GA directory</li>
<li>ant</li>
</ul>
<li>Compile Seam Booking Application:</li>
<ul>
<li>Go to the jboss-seam-1.0.1.GA/examples/booking directory</li>
<li>ant</li>
</ul>
</ol>
<b>Deploy the application:</b></br>
<ol>
<li>Start up Glassfish.</li>
<li>Start the database:&nbsp; <span style="font-style: italic;">&lt;glassfish
install dir&gt;</span>/bin/asadmin
start-database</li>
<li>Deploy jboss-seam-1.0.1.GA/examples/booking/build/jboss-seam-booking.ear</li>
</ol>
<b>Load the database:</b><br>
<ol>
  <li>Go to jboss-seam-1.0.1.GA/examples/booking/resources</li>
  <li>set your CLASSPATH so that it is:</li>
  <ul>
    <li>CLASSPATH=<span style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derbyclient.jar:<span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derbytools.jar:<span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derby.jar:.</li>
  </ul>
  <li>java -Dij.driver='org.apache.derby.jdbc.ClientDriver'
org.apache.derby.tools.ij</li>
  <li>At the Derby ij prompt connect to the default database:<br>
  </li>
  <ul>
    <li>connect 'jdbc:derby://localhost:1527//<span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/bin/sun-appserv-samples';</li>
    <ul>
      <li>For example: <span style="font-style: italic;">connect
'jdbc:derby://localhost:1527///home/work/glassfish/bin/sun-appserv-samples';</span></li>
    </ul>
    <li>run 'import.sql';</li>
  </ul>
</ol>
<ul>
  <li>Now the Seam application tables should be loaded.</li>
</ul>
<b>Run the application:</b><br>
<ul>
  <li>visit localhost:8080/seam-booking<br>
  </li>
</ul>
<hr style="width: 100%; height: 2px;">
<b>Code Change Summary</b>
<br/><br/>
The following changes apply to the Seam Booking application:<br/><br/>
./examples/booking/resources/import.sql<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;
Added trailing semicolons to each sql statement<br/></span> 
</span>
./examples/booking/resources/META-INF/persistence.xml<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;
Updated for application with
GlassFish</span> <span style="color: rgb(255, 0, 0);">and Java
Persistence<br>
</span></span>
./examples/booking/resources/META-INF/ejb-jar.xml<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;
Updated per EJB 3 schema: added schema namespace and <span
 style="font-style: italic;">&lt;interceptors&gt;</span> element<br/></span> 
</span>
./examples/booking/resources/WEB-INF/web.xml<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;
Added schema namespace<br/>----&gt;Updated JNDI lookup pattern<br/>----&gt;Disabled MyFaces StartupServletContextListener - we're using JSF 1.2<br/>----&gt;Added <span
 style="font-style: italic;">&lt;ejb-local-ref&gt;</span> elements for EJB applicaton actions<br/></span> 
</span>
./examples/booking/src/org/jboss/seam/example/booking/RegisterAction.java<br/>
./examples/booking/src/org/jboss/seam/example/booking/HotelSearchingAction.java<br/>
./examples/booking/src/org/jboss/seam/example/booking/BookingListAction.java<br/>
./examples/booking/src/org/jboss/seam/example/booking/LoginAction.java<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;
Updated sql statements passed to EntityManager.createQuery<br/></span> 
</span>
./examples/booking/src/org/jboss/seam/example/booking/User.java<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;Refer to table name 'Users'<br/></span> 
</span>
./examples/booking/view/conversations.xhtml<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;Added &lt;ui:composition&gt; element<br/></span> 
</span><br/>

The following change is to a Seam (JSF) custom component:<br/><br/>
                                                                                                                            
./src/ui/org/jboss/seam/ui/HtmlLink.java<br/>
<span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;Added encodeEnd method to properly end either an HTML input element or an HTML hyperlink element<br/></span> 
</span><br/></br>
All of these entries are in the seam-1.0.1.GA-booking-patch.zip file and can be reviewed.]]>

</content>
</entry>
<entry>
<title>JavaServer Faces In The Real World</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2006/06/javaserver_face_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-06-23T20:35:41Z</issued>
<id>tag:weblogs.java.net,2006:/blog/rogerk/252.5085</id>
<created>2006-06-23T20:35:41Z</created>
<summary type="text/plain">Often when you are &quot;heads down&quot; developing a technology, you forget about who might be using that technology.  And in the course of giving a presentation about the technology, you may hear a question or two like &quot;yeah... great....  but who is using this out there in the real world?&quot;..  Well.. we&apos;ve compiled an initial list of companies/sites out there that use JSF....</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[Often when you are "heads down" developing a technology, you forget about who might be using that technology.  And in the course of giving a presentation about the technology, you may hear a question or two like "yeah... great....  but who is using this out there in the real world?"..  Well.. we've compiled an initial list of companies/sites out there that use JSF....  That list can be found <a href="http://wiki.java.net/bin/view/Projects/RealWorldJSFLinks">here</a>.  Enjoy!
 ]]>

</content>
</entry>
<entry>
<title>Announce: JSF 1.2 Specification Errata</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2006/06/announce_jsf_12.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-06-06T17:01:19Z</issued>
<id>tag:weblogs.java.net,2006:/blog/rogerk/252.4970</id>
<created>2006-06-06T17:01:19Z</created>
<summary type="text/plain">A list of clarifications and corrections to the JSF 1.2 (JSR 252) specification has now been made available.</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[A list of clarifications and corrections to the JSF 1.2 (JSR 252) specification has now been made available.  The list can be found <a href="https://javaserverfaces.dev.java.net/jsf12-errata.html">here</a>.
There may be additions to this list of errata items, so check back.]]>

</content>
</entry>
<entry>
<title>Seam On GlassFish With Java Persistence</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2006/05/seam_on_glassfi.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-05-04T22:50:18Z</issued>
<id>tag:weblogs.java.net,2006:/blog/rogerk/252.4655</id>
<created>2006-05-04T22:50:18Z</created>
<summary type="text/plain">I&apos;ve outlined some steps for getting Seam (the JBoss application framework that unifies JSF and EJB 3.0) to run on GlassFish with Hibernate as the persistence layer.  Now, we&apos;ll see how we can have Seam running on GlassFish using the Java Persistence API as the persistence layer. </summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>Seam-GlassFish</title>
</head>
<body>
In&nbsp; <a
 href="http://weblogs.java.net/blog/rogerk/archive/2006/04/java_ee_sdk_run_1.html">Java
EE SDK Runs Seam</a><b> </b>I outlined some steps for getting <a
 href="http://www.jboss.com/products/seam">Seam</a> (the JBoss
application framework that unifies JSF and EJB 3.0) to run on <a
 href="https://glassfish.dev.java.net/">GlassFish</a> with Hibernate as
the persistence layer.&nbsp; Now, we'll see how we can have Seam
running on GlassFish with the <a
 href="https://glassfish.dev.java.net/javaee5/persistence/">Java
Persistence API</a> as the persistence layer.&nbsp; For completeness,
I'll go over the prerequisites and setup as described in <a
 href="http://weblogs.java.net/blog/rogerk/archive/2006/04/java_ee_sdk_run_1.html">Java
EE SDK Runs Seam</a> because their are some subtle differences along
the way.<br>
<a href="http://www.jboss.com/products/seam"
 style="text-decoration: underline;"></a><br>
Prerequisites:<br>
<ol>
  <li>A working build environment with <a href="http://ant.apache.org/">ant</a>,
at least <a href="http://java.sun.com/j2se/1.5.0/download.jsp">JDK 5</a>,
and <a href="https://glassfish.dev.java.net/public/downloadsindex.html#Official_supported_builds">GlassFish</a>
(build 43 or later).</li>
  <li>You'll need to use some of the Hibernate libraries that the Seam framework depends on:<br>
  </li>
  <ul>
    <li>Download and install <a
 href="http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=127784&amp;release_id=405151">Hibernate3
3.2cr1</a>.</li>
    <li>Download and install <a
 href="http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=156160&amp;release_id=405227">Hibernate
EntityManager 3.1 beta7</a>&nbsp;.&nbsp; Note that <span
 style="font-style: italic;">hibernate-entitymanager.jar</span> is not
required because we'll be using Java Persistence.&nbsp; However, <span
 style="font-style: italic;">hibernate-annotations.jar</span> is still
required, because the Seam framework uses classes from the Hibernate <span
 style="font-style: italic;">validator</span> package.<br>
    </li>
    <li>Copy the&nbsp;required hibernate jars into Glassfish lib dir.
The script <a
href="http://weblogs.java.net/blog/rogerk/archive/copyHibernateLibsJPersist.sh">here
      </a>contains the list of jars.</li>
    <li>Edit the script to make sure it references your Glassfish and
Hibernate install directories.</li>
    <li>Execute the script.<br>
    </li>
  </ul>
</ol>
Seam Setup:<br>
<ol>
  <li>Download and install the Seam 1.0beta2 release from <a
href="http://prdownloads.sourceforge.net/jboss/jboss-seam-1.0beta2.zip?download">here</a>.&nbsp;
You should see a jboss-seam-1.0beta2 directory.</li>
  <li>Get the zip files: <a
 href="http://weblogs.java.net/blog/rogerk/archive/seam-core-patch.zip">seam-core-patch.zip</a>
and <a
href="http://weblogs.java.net/blog/rogerk/archive/seam-booking-jpersist-patch.zip">seam-booking-jpersist-patch.zip</a>
.&nbsp; <br>
  </li>
  <li>Go to the jboss-seam-1.0beta2 directory and unzip
seam-core-patch.zip and seam-booking-jpersist-patch.zip.</li>
</ol>
Compilation Procedure:<br>
<ol>
  <li>Copy <span style="font-style: italic;">&lt;glassfish install dir &gt;</span>/lib/javaee.jar
to jboss-seam-1.0beta2/lib directory.</li>
  <li>Copy jboss-seam-1.0beta2/lib/jboss-common.jar <span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/lib&nbsp;
(needed for JBoss Logger)<br>
  </li>
  <li>Compile Seam core classes:</li>
  <ul>
    <li>Create an empty jboss-seam-1.0beta2/src/test directory (the
build file is looking for this directory that is not there from the
seam zip file).<br>
    </li>
  </ul>
  <ul>
    <li>Go to jboss-seam-1.0beta2 directory;&nbsp; ant;</li>
  </ul>
  <li>Compile Seam Booking Application:</li>
  <ul>
    <li>Copy jboss-seam-1.0beta2/jboss-seam-ui.jar to
jboss-seam-1.0beta2/examples/booking/resources/WEB-INF/lib</li>
    <li>Go to jboss-seam-1.0beta2/examples/booking</li>
    <li>ant</li>
  </ul>
</ol>
Deploy the application:<br>
<ol>
  <li>Start up Glassfish.</li>
  <li>Start the database:&nbsp; <span style="font-style: italic;">&lt;glassfish
install dir&gt;</span>/bin/asadmin
start-database</li>
  <li>Deploy
jboss-seam-1.0beta2/examples/booking/build/jboss-seam-booking.ear</li>
</ol>
Load the database:<br>
<ol>
  <li>Go to jboss-seam-1.0beta2/examples/booking/resources</li>
  <li>set your CLASSPATH so that it is:</li>
  <ul>
    <li>CLASSPATH=<span style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derbyclient.jar:<span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derbytools.jar:<span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/javadb/lib/derby.jar:.</li>
  </ul>
  <li>java -Dij.driver='org.apache.derby.jdbc.ClientDriver'
org.apache.derby.tools.ij</li>
  <li>At the Derby ij prompt connect to the default database:<br>
  </li>
  <ul>
    <li>connect 'jdbc:derby://localhost:1527//<span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/bin/sun-appserv-samples';</li>
    <ul>
      <li>For example: <span style="font-style: italic;">connect
'jdbc:derby://localhost:1527///home/work/glassfish/bin/sun-appserv-samples';</span></li>
    </ul>
    <li>run 'import.sql';</li>
  </ul>
</ol>
<ul>
  <li>Now the Seam application tables should be loaded.</li>
</ul>
Run the application:<br>
<ul>
  <li>visit localhost:8080/seam-booking<br>
  </li>
</ul>
<br>
You can refer to <a
 href="http://weblogs.java.net/blog/rogerk/archive/2006/04/java_ee_sdk_run_1.html">Java
EE SDK Runs Seam</a><b> </b>for an explanation of the Seam core
modules and the Seam Booking application modules that required
modification.&nbsp; Those modifications are essentially the same with
the exception of the following modifications to some Booking
application modules:<br>
<br>
&nbsp;&nbsp;&nbsp; examples/booking/resources/META-INF/persistence.xml<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;"><span style="color: rgb(255, 0, 0);">----&gt;
updated for application with
GlassFish</span> <span style="color: rgb(255, 0, 0);">and Java
Persistence<br>
</span></span><span style="font-style: italic;"></span>&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/BookingListAction.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/HotelBookingAction.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/LoginAction.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/RegisterAction.java<span
 style="font-style: italic;"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="color: rgb(255, 0, 0);">----&gt; made SQL queries complete for
Java Persistence.&nbsp; </span><span style="color: rgb(255, 0, 0);"></span><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp; <br>
</span><span style="font-style: italic;"></span><br>
<br>
<br>
</body>
</html>]]>

</content>
</entry>
<entry>
<title>Java EE SDK Runs Seam</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2006/04/java_ee_sdk_run_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-04-28T19:30:23Z</issued>
<id>tag:weblogs.java.net,2006:/blog/rogerk/252.4596</id>
<created>2006-04-28T19:30:23Z</created>
<summary type="text/plain">I am happy to report that Seam (the JBoss application framework that unifies JSF and EJB 3.0) runs on GlassFish, the Open Source Application Server from which the Java EE SDK is built.</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>Seam-GlassFish</title>
</head>
<body>
I am happy to report that <a href="http://www.jboss.com/products/seam">Seam</a>
(the JBoss application framework that unifies JSF and EJB 3.0) runs on <a
 href="https://glassfish.dev.java.net/">GlassFish</a>, the Open Source
Application Server from which the Java EE SDK is built.&nbsp; This
required some modifications and rebuilding of Seam source code, mainly
because of the repackaging of EJB classes in accordance to the latest
EJB specification implementation.&nbsp; JBoss is making the required
changes, but for those of you who can't wait, I'll describe those
changes and setup necessary to get a Seam application up and running on
GlassFish.&nbsp; Also, I'd like to point out, that these instructions
are for the Seam 1.0beta2 release.&nbsp; Recently JBoss has released a
later version, but the interceptor related packaging changes are not
there.&nbsp;&nbsp; First, let's install the
patches and get the Seam Booking application up and running.<br>

<br>
Prerequisites:<br>
<ol>
  <li>A working build environment with <a href="http://ant.apache.org/">ant</a>,
at least <a href="http://java.sun.com/j2se/1.5.0/download.jsp">JDK 5</a>,
and <a
 href="https://glassfish.dev.java.net/public/downloadsindex.html#Official_supported_builds">GlassFish</a>
(build 43 or later).</li>
  <li>For this application, you will also need to make sure you have
the compatable Hibernate libraries with GlassFish:</li>

  <ul>
    <li>Download and install <a
 href="http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=127784&amp;release_id=405151">Hibernate3
3.2cr1</a> or later.</li>
    <li>Download and install <a
 href="http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=156160&amp;release_id=405227">Hibernate
EntityManager 3.1 beta7</a>&nbsp;or later.</li>
    <li>Copy the&nbsp;required hibernate jars into Glassfish lib dir.
The script <a
 href="http://blogs.sun.com/roller/resources/GlassFishPersistence/copyHibernateLibs.sh">here
      </a>contains the list of jars.</li>

    <li>Edit the script to make sure it references your Glassfish and
Hibernate install directories.</li>
    <li>Execute the script.<br>
    </li>
  </ul>
</ol>
Seam Setup:<br>
<ol>
  <li>Download and install the Seam 1.0beta2 release from <a
 href="http://prdownloads.sourceforge.net/jboss/jboss-seam-1.0beta2.zip?download">here</a>.&nbsp;

You should see a jboss-seam-1.0beta2 directory.</li>
  <li>Get the zip files: <a
 href="http://weblogs.java.net/blog/rogerk/archive/seam-core-patch.zip">seam-core-patch.zip</a>
and <a
 href="http://weblogs.java.net/blog/rogerk/archive/seam-booking-patch.zip">seam-booking-patch.zip</a>
. <br>
  </li>
  <li>Go to the jboss-seam-1.0beta2 directory and unzip
seam-core-patch.zip and seam-booking-patch.zip.</li>
</ol>

Compilation Procedure:<br>
<ol>
  <li>Copy <span style="font-style: italic;">&lt;glassfish install
dir&gt;</span>/lib/javaee.jar
to jboss-seam-1.0beta2/lib directory.</li>
  <li>Copy jboss-seam-1.0beta2/lib/jboss-common.jar <span
 style="font-style: italic;">&lt;glassfish install dir&gt;</span>/lib&nbsp;
(needed for JBoss Logger)<br>
  </li>

  <li>Compile Seam core classes:</li>
  <ul>
    <li>Create an empty jboss-seam-1.0beta2/src/test directory (the
build file is looking for this directory that is not there from the
seam zip file).<br>
    </li>
  </ul>
  <ul>
    <li>Go to jboss-seam-1.0beta2 directory;&nbsp; ant;</li>

  </ul>
  <li>Compile Seam Booking Application:</li>
  <ul>
    <li>Copy jboss-seam-1.0beta2/jboss-seam-ui.jar to
jboss-seam-1.0beta2/examples/booking/resources/WEB-INF/lib</li>
    <li>Go to jboss-seam-1.0beta2/examples/booking</li>
    <li>ant</li>
  </ul>

</ol>
Deploy and run the application:<br>
<ol>
  <li>Start up Glassfish.</li>
  <li>Start the database:&nbsp; <span style="font-style: italic;">&lt;glassfish
install dir&gt;</span>/bin/asadmin
start-database</li>
  <li>Deploy
jboss-seam-1.0beta2/examples/booking/build/jboss-seam-booking.ear</li>
  <li>Visit localhost:8080/seam-booking<br>

  </li>
</ol>
Now, here is an explanation of changed modules.&nbsp; The current JBoss
Seam codebase is not up to date with the latest EJB specification (and
implementation - as in GlassFish).&nbsp; Seam classes still reference
EJB interceptor related classes in the <span
 style="font-style: italic;">javax.ejb</span> package, but these now
exist in the <span style="font-style: italic;">javax.interceptor</span>
package.&nbsp; JBoss will be updating their source, but I am not clear
on when that will happen.<br>

<br>
Core classes:<br>
&nbsp;&nbsp;&nbsp; src/main/org/jboss/seam/Component.java<br>
&nbsp;&nbsp;&nbsp; src/main/org/jboss/seam/ejb/SeamInterceptor.java<br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/BijectionInterceptor.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/BusinessProcessInterceptor.java&nbsp;&nbsp;
<br>

&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/ConversationInterceptor.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/Interceptor.java&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/JavaBeanInterceptor.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/OutcomeInterceptor.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;

src/main/org/jboss/seam/interceptors/RemoveInterceptor.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/RollbackInterceptor.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/SeamInvocationContext.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/interceptors/ValidationInterceptor.java&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; interceptor package changes
described above</span><br>

&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/jsf/SeamPhaseListener.java&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; moved initilialization of
SeamVariableResolver, SeamNavigationHandler, SeamStateManager to<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

faces-config.xml, so they get created at startup.</span><br>
&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/jsf/SeamStateManager.java&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; new class taken from
StateManagerInterceptor class in SeamPhaseListener</span><br>
&nbsp;&nbsp;&nbsp; src/main/META-INF/faces-config.xml&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----&gt; <span
 style="font-style: italic;">defines</span> <span
 style="font-style: italic;">SeamVariableResolver,
SeamNavigationHandler, SeamStateManager<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----&gt;
modified component definition for HtmlQueryTable<br>
</span>&nbsp;&nbsp;&nbsp;
src/main/org/jboss/seam/mock/MockServletContext.java&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; stubbed in&nbsp; public String
getContextPath() method<br>
<br>

</span>Booking Application Modules:<br>
&nbsp;&nbsp;&nbsp; examples/booking/resources/import.sql<br>
&nbsp;&nbsp;&nbsp; examples/booking/resources/META-INF/persistence.xml<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; updated for application with
GlassFish</span><br>
&nbsp;&nbsp;&nbsp; examples/booking/resources/WEB-INF/web.xml<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; reference 2.5 schema, etc..</span><br
 style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
----&gt; modified JNDI name pattern for EJB lookups</span><br
 style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
----&gt; disabled MyFaces StartupServletContextListener (not compatable
with JSF 1.2)</span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
----&gt; added &lt;ejb-local-ref&gt; elements for EJB modules</span><br>

&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/BookingListAction.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/ChangePasswordAction.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/HotelBookingAction.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/LoggedInInterceptor.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/LoggedIn.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/LoginAction.java<br>

&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/LogoutAction.java<br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/RegisterAction.java<br>
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
----&gt; interceptor package changes described above</span><br>
&nbsp;&nbsp;&nbsp;
examples/booking/src/org/jboss/seam/example/booking/User.java<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; create "Users" table and
reference it as "user" (User is reserved in javaee5)</span><br>

&nbsp;&nbsp;&nbsp; examples/booking/view/main.xhtml<br>
&nbsp;&nbsp;&nbsp; examples/booking/view/template.xhtml<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="font-style: italic;">----&gt; added missing JSF "form" tags</span><br>
<br>
<br>
</body>
</html>]]>

</content>
</entry>
<entry>
<title>Open JavaServer Faces</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2005/08/open_javaserver.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-08-24T17:40:02Z</issued>
<id>tag:weblogs.java.net,2005:/blog/rogerk/252.3147</id>
<created>2005-08-24T17:40:02Z</created>
<summary type="text/plain">I&apos;m pleased to announce that Sun&apos;s implementation of JavaServer Faces is now open source,  and it is available under the Common Development and Distribution License (CDDL).</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
<![CDATA[In its continuing open-source effort, Sun has made the source code of its implementation of JavaServer Faces available under the 
<a href="http://www.opensource.org">OSI</a> approved Common Development and Distribution License (CDDL).  More information about that license can be found <a href="http://www.opensource.org/licenses/cddl1.php">here</a>.
JavaServer Faces has had external contributions, and this open-source strategy will make it easier to get contributions into the technology.  The news comes just as JavaServer Faces is ramping up for the start of its 2.0 release - a release that promises exciting new features.
So, you are certainly encouraged to get involved.  Want to get involved?  You can start <a href="https://javaserverfaces.dev.java.net/faq.html">here</a>.]]>

</content>
</entry>
<entry>
<title>Ajaxian JavaOne 2005 ?</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/rogerk/archive/2005/06/ajaxian_javaone.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-06-30T19:35:29Z</issued>
<id>tag:weblogs.java.net,2005:/blog/rogerk/252.2810</id>
<created>2005-06-30T19:35:29Z</created>
<summary type="text/plain">Was AJAX the big splash at JavaOne this year?</summary>
<author>
<name>rogerk</name>

<email>Roger.Kitain@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/rogerk/">
Well.. It&apos;s the last day at JavaOne 2005.  I attended some good web-tier sessions, and yes, I admit it - I too was caught up in the AJAX hype.
The web-tier sessions in general, get good attendance, but, sprinkle a little AJAX in there, and you have electricity in the air!  Javascript has been around forever, and folks have been adding interactivity (DHTML..) to their web pages for years.  But I think the commonality of XMLHttpRequest across more browsers, coupled with a new buzzword - AJAX - has generated &quot;renewed&quot; excitement in this area.

So... it may have been AJAX that left a mark at this year&apos;s JavaOne.
What about next year?



</content>
</entry>

</feed>