Tech all over the world
Tuesday, February 28, 2006
  Sun Developer Network Program Newsletter

Sun Developer Network Program News: February 2006

You are receiving this e-mail because you elected to receive e-mail from Sun Microsystems, Inc. To update your communications preferences, please see the link at the bottom of this message. We respect your privacy and post our privacy policy prominently on our Web site http://sun.com/privacy/

Please do not reply to the mailed version of the newsletter, this alias is not monitored. Feedback options are listed in the footer for both content and delivery issues.

February 2006
   
Sun Developer Network
NEWSLETTER
The Sun Developer Network Program Newsletter is a monthly email informing developers of the latest news, resources, programs, and events available through the Sun Developer Network.
 
 
 » NetBeans Enterprise Pack 5.5 Preview. Now Available for Download
This preview release introduces UML modeling, XML tools, and Web services orchestration to the NetBeans community. It is available as an integrated bundle along with NetBeans IDE 5.5 Preview and Sun Java System Application Server Platform Edition 9 Beta.

 

WHAT'S NEW
 
FEATURES


 » Java Studio Creator 2 Offers Across the Board Improvement
Java Studio Creator presents a manageable interface that has the functionality to carry out the task at hand without a developer getting lost in thousands of different options and views.

 
 
PROGRAM ENHANCEMENTS


 » Ask the Experts
February 27, 2006 - March 3, 2006
Topic: Java Plug-In Technology
Experts:
  • Dennis Gu, member of technical staff,
    Java Deployment team, Sun Microsystems
  • Danielle Pham Senior Staff Engineer,
    Java Deployment team, Sun Microsystems
  • Mike Lei member of technical staff,
    Java Deployment team, Sun Microsystems
Java Plug-in technology establishes a connection between popular browsers and the Java platform. This connection enables applets on web sites to be run within a browser on the desktop. Got a question about Java Plug-In technology? Post it during this session and get answers from three key members of the Java Deployment team.

 
 » New Training for Java Studio Creator 2
Gail and Paul Anderson, authors of the Sun Press publication Java Studio Creator Field Guide, Second Edition, are now available to teach the Java Studio Creator 2 IDE to developer workgroups. Their course, developed to closely follow the topics and sample applications presented in the Field Guide, covers a range of subjects to familiarize teams with using the product.

 

ANNOUNCEMENTS
 
 » Get the Preview of the Java EE 5 SDK!
Download the Java EE 5 SDK preview and get a feel for the next-generation Java EE 5 platform, which makes building robust, scalable enterprise applications easier than ever and is the perfect platform for implementing SOA and Web 2.0 applications.

 
 » Available for Download: Sun Java Studio Creator 2
Built on NetBeans 4.1, Sun Java Studio Creator 2 includes features like a new set of JavaServer Faces components, support for building JSR-168 portlets, easy access to databases, a streamlined application model, and more.

 
 » InsIDE Stories Developer Contest. Deadline Extended
Good News! You've got more time to tell James Gosling how Sun Java Studio Enterprise 8 improved your productivity. Don't miss the opportunity to win a Sun Ultra 20 Workstation and be featured on developers.sun.com.

 
 » 2006 JavaOne Conference: Refer a Friend
Refer a friend to the JavaOne conference, May 16-19, at Moscone Center in San Francisco, and receive a t-shirt or even an iPod Nano music player (while supplies last)!

 
 » Advance Your Skills at Sun Tech Days
Tap the power of Java technology and the Solaris platform with in-depth technical training.

 
 » Developer Survey
IDC, an independent world-wide market research company, is conducting a worldwide survey to get a developer's perspective on open source software in collaboration with several large IT vendors, including Sun Microsystems. Survey results will be made available in a variety of forms to information technology vendors. Be assured that the information you provide is intended to be used only in aggregation with the answers of other respondents. The survey is Web-based, and will be open for six weeks starting February 20, 2006. Please take a moment to give us your perspective!

 

RESOURCES 

»

Java User Groups
Join one of more than 500 Java User Groups in over 100 countries or start your own.
 

»

Java Technology Blogs
Find out what James Gosling and other influential folks in the Java industry are saying about Java technology topics and more.
 

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
If you would like a reply to your comment, please submit your email address:
Note: We may not respond to all submitted comments.
Comments and Contact Information:

For technical assistance about Newsletter delivery, broken links, or subscribe/unsubscribe help, fill out the web form.
Write to us at: SDN Editorial Team, MS: UMPK18-113, 18 Network Circle, Menlo Park, CA 94025, USA

IMPORTANT: Please read our Licensing, Terms of Use, and Privacy policies:
http://developer.java.sun.com/berkeley_license.html
http://www.sun.com/share/text/termsofuse.html

Privacy Statement: Sun respects your online time and privacy (http://sun.com/privacy). You have received this based on your email preferences. If you would prefer not to receive this information, please follow the steps at the bottom of this message to unsubscribe.

© 2006 Sun Microsystems, Inc. All Rights Reserved. For information on Sun's trademarks see: http://sun.com/suntrademarks
Java, J2EE, J2SE, J2ME, and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.

Sun Microsystems, Inc. 10 Network Circle, MPK10-209 Menlo Park, CA 94025 US

This service may provide, or third parties may provide, links to other Internet sites or resources. Because Sun has no control over such sites and resources, you acknowledge and agree that Sun is not responsible for the availability of such external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods or services available on or through any such site or resource.



Please unsubscribe me from this newsletter.


 
Monday, February 27, 2006
  February 2006 Java Enterprise Technologies Newsletter

You are receiving this e-mail because you elected to receive e-mail from Sun Microsystems, Inc. To update your communications preferences, please see the link at the bottom of this message. We respect your privacy and post our privacy policy prominently on our Web site http://sun.com/privacy/

Please do not reply to the mailed version of the newsletter, this alias is not monitored. Feedback options are listed in the footer for both content and delivery issues.

February 27, 2006
Enterprise Java Technologies
NEWSLETTER
Welcome to the Enterprise Java Technologies Newsletter. Here you'll find links to the latest products, tools, resources, and events relating to development with the Java Platform, Enterprise Edition (Java EE, formerly known as J2EE).
PRODUCT AND TECHNOLOGY RELEASES

 

The following Java SE products and technologies were recently released.

 

 
 » NetBeans IDE 5.0 Released! (February 8, 2006)
NetBeans IDE 5.0 features include a fantastic new GUI-builder (Matisse); Sun Application Server, WebLogic, and JBoss support; Struts and JSF support; and tools for extending the NetBeans platform.
Read more.
Download now.

 
 » JSR 56 Java Web Start 6.0 Maintenance Release (February 8, 2006)
The Java Web Start specification of protocols and APIs enables easy deployment of Java technology applications across the web.

 
 » JSR 154 Java Servlet 2.5 Maintenance Review Draft 2 (February 14, 2006)
This specification builds on servlet specification version 2.3 by enhancing existing features and adding new facilities.

 
 » JSR 252 JavaServer Faces 1.2 Proposed Final Draft 2 (February 15, 2006)
This draft updates the JavaServer Faces specification with exciting new features.

 
 » JSR 245 JavaServer Pages 2.1 PFD 2 (February 16, 2006)
This revision of the JSP specification improves alignment with JavaServer Faces (JSF) and enhances ease of development.

 
 » New Real-Time Java (JSR 1) Product (February 17, 2006)
The Sun Java Real-Time System 1.0 provides predictability, determinism, and low latencies to meet real-time requirements. Avoid garbage-collection pauses, handle thread priorities, scheduling, and async events with Java Real-Time!

 
 » NetBeans IDE Enterprise Pack 5.5 Preview (February 17, 2006)
Launching your first SOA project? Already engaged in developing your enterprise's SOA project? The NetBeans Enterprise Pack 5.5 Preview will help you meet your needs.

 

RESOURCES

 

Resources: Learn more about and get "hands-on" training for Java SE technologies through the following resources.
 
 
TECHNICAL ARTICLES
 

 »

How to Write a Helpful Bug Report
Learn how to file a bug report that will help Sun engineers focus their investigation and fix bugs more quickly.

 
 » Web Tier to Go With Java EE 5: Summary of New Features in JSP 2.1 Technology
Read about new features in JSP 2.1 technology and see how version 2.1 has resolved the software's former incompatibility with JavaServer Faces technology.

 
 » Introduction to the Java EE 5 Platform
Read about streamlined features and added convenience in the Java EE 5 platform that help improve performance, reduce development time, and get products to market sooner.
 
 
VIEWPOINTS

 

 »
Meet Kohsuke Kawaguchi, Staff Engineer and XML Schema Developer at Sun Microsystems
Kohsuke Kawaguchi discusses his work with XML schema languages, the work-style differences between Japan and the United States, and the transition from C++ to the Java programming language.
 
 
TECH TIPS
 

 »

What's New in JAXB 2.0

 
 » Monitoring Web Services
 
 
BOOKS
 

 »

Book Review: POJOs in Action
Manning's new book shows you how to organize and encapsulate domain logic, access databases, manage transactions, and handle database concurrency using plain old Java objects (POJOs).
 

 »

Sun Microsystems Press -- The Java Series
Provides the inside information you need to build effective, robust, and portable applications and applets. An indispensable resource for Java platform developers.
 
 
NEWSLETTERS
 

 »

Sun Student Connection Newsletter
Brings you the latest news on open source developer tools, technology resources, and Java technology-based Internet games.
 

 »

Core Java Technologies Newsletter
Catch the latest highlights of the latest Core Java technology releases and tools.
 

 »

Mobility Developer Newsletter
Catch the latest highlights of the latest releases of Wireless and Java Card technologies.
 

 »

Sun Developer Network Program News
Providing news and information of value to SDN users including product announcements, user group meetings, early access programs and more.
 
 
COMMUNITY
 

 »

Java Community Process Includes CDDL License
JCP allows JSR spec leads to release the Reference Implementation and the CTK under a variety of licenses, including open-source licenses such as CDDL.

 
 » Common Code. Uncommon Results.
Capitalize, collaborate, and contribute to the growing network of open communities. Discover tools and resources to build and deploy your software applications.

 
 » Tell the 2006 JavaOne Conference Organizers What You Want
- What would you like to see at the JavaOne conference?
- What topics interest you?
- What types of talks are the best?
 
 
TRAINING
 

 »

Top Five Reasons to Get Certified by Sun
Read the list of five compelling reasons to get certified in Java Technology or the Solaris OS from Sun.

 
 » Popular Java Technology Courses Now Available Online
Sun's five most popular instructor-led courses are available as self-paced online courses with downloadable labs. See course numbers WJB-110A, WJB-275A, WJB-310A, WJB-314A, WJB-351A.

 
 » Java Certifications Available in Multiple Languages
Did you know that most of Sun's Java technology certification exams are available in multiple languages? See the complete list of available languages.

 

ANNOUNCEMENTS

 »

Duke's Choice Awards 2006 - Now Accepting Nominations!
The popular Duke's Choice Awards are going to be hosted at the 2006 JavaOne Conference for the fourth year. These awards celebrate the extreme innovation in the world of Java technology. We are accepting nominations now!
 

 »

Java SE 6 (Mustang) Regressions Challenge Contest
We're looking for regressions and we need your help! Join our Regressions Challenge contest and vie for one of five Ultra 20 workstations from Sun.
 

 »

Free Oracle Database With Purchase of UltraSPARC IV & IV+ Servers and One Year of DB Support
Purchase or upgrade a Sun Fire UltraSPARC IV or IV+ server and get Oracle Database Enterprise Edition licenses free with your first year of database maintenance through Sun.
 

 »

Win a Sony PlayStation Portable
Download the J2EE 1.4 SDK now and share your experience in using the Sun Java System Application Server 8.2! This is your chance to win a Sony PlayStation Portable!
 

 »

Pick Your Server and Save Big on Web Services
Get 78% off fully supported Sun Java Web Infrastructure Suite when you buy a qualified Sun Fire Server.
 

 »

Reap What You Sow
Purchase a Sun Fire T2000 Server and save up to 25% on select Sun training courses.
 

 »

CoolThreads Prize for Innovation Contest
Win $50,000 and a free Sun Fire T2000 server! Enter the CoolThreads Prize for Innovation Contest -- develop applications to run the Internet of the future.
 

EARLY ACCESS


The following J2EE products and technologies were made available through the Early Access Release Program this month.
 

»

Get the Preview of the Java EE 5 SDK!
(February 8, 2006)

Download the Java EE 5 SDK preview and get a feel for the next generation Java EE 5 platform! Java EE 5 makes building robust, scalable enterprise applications easier than ever and is the perfect platform for implementing SOA and Web 2.0 applications. This preview also includes Sun Java System Application Server PE 9 beta!

 

EVENTS

»

JavaUK06: The UK's Premier Sun Java Technology Event for Developers
Learn about the latest developments in Java technology and Sun software:
-New advancements in Java Client, mid-tier, and enterprise technologies
-Integration and interoperability
-Solaris Operating System

 

»

2006 JavaOne Conference: Refer a Friend
Refer a friend to the JavaOne conference, May 16-19, at San Francisco's Moscone Center and receive a T-shirt or even an iPod Nano music player (while supplies last)!

 

»

Advance Your Skills at Sun Tech Days
Tap the power of Java technology and the Solaris platform with in-depth technical training. Learn more and register now!

 

»

More Events

 

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Comments and Contact Information: There are three ways to send your feedback about the Enterprise Java Technologies Newsletter:

For comment about the content of this newsletter, fill out the Rate and Review form, above.
For technical assistance about Newsletter delivery, broken links, or subscribe/unsubscribe help, fill out the web form.
Write to us at: SDN Editorial Team, MS: UMPK18-113, 18 Network Circle, Menlo Park, CA 94025, USA

Subscribe/Unsubscribe: Subscribe to other Java technology newsletters:
  • Java Technology Fundamentals Newsletter. Learn the basics of the Java programming language and keep up-to-date on additions to the New-to-Java Programming Center.
  • Core Java Technologies Newsletter. Learn about new products, tools, resources, and events of interest to developers working with core Java technologies.
  • Mobility Developer Newsletter. Learn about the latest releases, tools, and resources for developers working on wireless and Java Card technologies and applications.
You can subscribe to these and other Sun Developer Network publications on the SDN Newsletters and Publications page
- To subscribe, visit the SDN Newsletters and Publications page, select the newsletters you want to subscribe to and click "Update."
- To unsubscribe, go to the subscriptions page, uncheck the appropriate checkbox, and click "Update."

IMPORTANT: Please read our Licensing, Terms of Use, and Privacy policies:
http://developer.java.sun.com/berkeley_license.html
http://www.sun.com/share/text/termsofuse.html

Privacy Statement: Sun respects your online time and privacy (http://sun.com/privacy). You have received this based on your email preferences. If you would prefer not to receive this information, please follow the steps at the bottom of this message to unsubscribe.

Archives: You'll find the Enterprise Java Technologies Newsletter archives at:
http://java.sun.com/developer/techDocs/Newsletters/jdc_newsletters.html

© 2006 Sun Microsystems, Inc. All Rights Reserved. For information on Sun's trademarks see: http://sun.com/suntrademarks
Java, J2EE, J2SE, J2ME, and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.

Sun Microsystems, Inc. 10 Network Circle, MPK10-209 Menlo Park, CA 94025 US



Please unsubscribe me from this newsletter.


 
Saturday, February 25, 2006
  Enterprise Java Technologies Tech Tips, Feb. 25, 2006 (Renderkits, Accessing a Secure Bean)
You are receiving this e-mail because you elected to receive e-mail from Sun Microsystems, Inc. To update your communications preferences, please see the link at the bottom of this message. We respect your privacy and post our privacy policy prominently on our Web site http://sun.com/privacy/

Please do not reply to the mailed version of the newsletter, this alias is not monitored. Feedback options are listed in the footer for both content and delivery issues.
  Welcome to the Enterprise Java Technologies Tech Tips.
Enterprise Java Technologies
TECHNICAL TIPS
February 25, 2006
View this issue as simple text
In this Issue
 
Welcome to the Enterprise Java Technologies Tech Tips for February 25, 2006. Here you'll get tips on using enterprise Java technologies and APIs, such as those in Java 2 Platform, Enterprise Edition (J2EE) and Java Platform, Enterprise Edition (Java EE).

This issue covers:

» Using AJAX With Non-HTML Markup in JSF
» Accessing a Secure Enterprise Bean From a Java Client or Through Java Web Start Technology

These tips were developed using an open source reference implementation of Java EE 5 called GlassFish. You can download GlassFish from the GlassFish Community Downloads page.

You can download the sample archive for the tip Using AJAX With Non-HTML Markup in JSF. There are two sample archives for the tip "Accessing a Secure Enterprise Bean From a Java Client". One is for a standalone client example, the other is for a Java Web Start example. You can download the archive for the Java Web Start example. You can download the archive for the standalone client example.

Any use of this code and/or information below is subject to the license terms.

See the Subscribe/Unsubscribe note at the end of this newsletter to subscribe to Tech Tips that focus on technologies and products in other Java platforms.

USING AJAX WITH NON-HTML MARKUP IN JSF
 
by Roger Kitain

JavaServer Faces (JSF) technology is a framework that simplifies building user interfaces for Java EE and J2EE applications. The March 24, 2004 Tech Tip, Introducing JavaServer Faces Technology gave a brief overview of the technology. It also showed how to create a JSF application that includes GUI components that are modeled by the JSF framework. A later tip showed how to create custom components with JavaServer Faces technology. Since the publishing of those tips, the technology has gone to the 1.2 level. One of the new features in JSF 1.2 is the ability to support multiple render kits in a single JSF application. In JSF, render kits are used to present the user interface in a markup such as HTML. JSF comes with an HTML render kit, but you could write a render kit to display user interface components in other markup languages such as Scalable Vector Graphics (SVG) or XML User Interface Language (XUL).

You might want to take advantage of the strengths that each markup language provides by combining them in a single JSF application. For example, you can use SVG to create sophisticated graphics and animations for an application. However SVG does not have a widget set which includes buttons or other components. You have to create these widgets using a markup. In contrast, XUL has a complete set of user interface controls that can easily be used, but it lacks the graphical capabilities that SVG provides. Common to both of these markups is the lack of a built-in form submission mechanism like the one available in HTML. However Asynchronous JavaScript and XML (AJAX) can be used with some JSF 1.2 features to effectively produce form submissions from non-HTML markup. In this tip you'll see a demonstration that uses AJAX and three render kits (HTML, SVG, and XUL) in a JSF application. (For more information about AJAX see the November 22, 2005 Tech Tip, Using AJAX with Java Technology.)

JSF Life Cycle Example

User interactions with a JSF application are processed in a series of steps known as the "JSF life cycle". Typically the life cycle is illustrated as a set of connected boxes, with each box identifying a phase in the process. Lines with arrows show the flow from one phase to the next. Accompanying this tip is an example JSF application that displays an animated version of the JSF life cycle. As mentioned earlier, the application uses the HTML, SVG and XUL render kits.

The following diagram shows the flow of the demo between the pages of different markup:

The application begins with the display of an HTML page that gives some background and design details pertinent to the demonstration.

This page is produced with the standard HTML render kit. If you click the Next button at the bottom of the page it displays an SVG page that is rendered with an SVG render kit. The SVG page graphically illustrates the JSF life cycle.

If you click on any box that represents a life cycle phase (such as Restore View Phase), it uses AJAX to generate a form submission. In response, you should see an XUL page that displays more detail about that JSF life cycle phase.

Below the JSF life cycle illustration is a larger box that contains various buttons with labels such as Initial Request and Validation Error. If you click on these buttons you'll see an animated display of a specific process flow through the life cycle phases (for instance, the process flow for handling an initial request).

Let's take a look at some of the code for the demonstration.

Posting From The Client

First, let's examine the SVG page. Here is a snippet of the SVG page written with JSF tags:

    <%@ page contentType="image/svg+xml"%>    <%@ taglib uri="http://java.sun.com/jsf/svg" prefix="g" %>    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>    ...       <f:view renderKitId="SVG" >          <g:form id="form">    ...             <g:commandButton id="restore" width="120"                     height="50" x="100" y="100" type="submit"                    action="xul-restore"                    style="stroke:black; fill:#8470ff;" >                  <g:outputText x="130" y="120"                     textAnchor="middle" value="Restore" />                  <g:outputText x="135" y="140"                     textAnchor="middle" value="View" />             </g:commandButton>    ...          </g:form>       </f:view> 

Notice the page directive that indicates the content type of the page:

    <%@ page contentType="image/svg+xml"%> 

and the tag that indicates that SVG is the rendering technology for the page:

    <f:view renderKitId="SVG" > 

You can learn more about the directives, tags, and attributes that need to appear on a page that uses a render kit such as SVG, in the article Creating and Using a Custom Render Kit.

In response to the information on the SVG page, the SVG render kit on the server produces the following SVG markup:

    <svg xmlns="http://www.w3.org/2000/svg"         xmlns:xlink="http://www.w3.org/1999/xlink">    ...      <script xlink:href="/jsf-renderkits/src/script/http-svg.es">      </script>      <script xlink:href="/jsf-renderkits/src/script/lifecycle.es">      </script>      <g id="form" method="post"           action="/jsf-renderkits/render/svg.jsp">    ...        <g id="form:restore" onclick="form_post(evt)">          <rect width="120" height="50" x="100" y="100"              style="stroke:black; fill:#8470ff;"></rect>          <text x="100" y="150" text-anchor="middle"></text>          <text x="130" y="120">Restore</text>          <text x="135" y="140">View</text>        </g>    ...        <text name="javax.faces.ViewState"         id="javax.faces.ViewState" value="_id4:_id6"            visibility="hidden">_id4:_id6</text>        <text name="javax.faces.RenderKitId"            id="javax.faces.RenderKitId" value="SVG"            visibility="hidden">SVG</text>      </g>    <script><![CDATA[    function form_post(evt) {      var control = evt.target;      var form = getForm(control);      var postData = getPostData(form, control);      var url = "/jsf-renderkits/render/svg.jsp";      sendRequest(url, postData);    }    //]]>    </script>    </svg> 

This code is produced by various renderers in the SVG render kit. The encodeBegin() method of the FormRenderer produces the following ECMAScript file references:

    <script xlink:href="/jsf-renderkits/src/script/http-svg.es">    </script>    <script xlink:href="/jsf-renderkits/src/script/lifecycle.es">    </script> 

and also the starting "form" group:

   <g id="form" method="post"        action="/jsf-renderkits/render/svg.jsp"> 

The action attribute in the starting "form" group is used to identify this SVG <g> element as a "form" element. The <g> element is widely used in SVG.

The ButtonRenderer and TextRenderer encode methods produce the starting and ending group elements for the button control, and the associated dimensions and label for the button control:

    <g id="form:restore" onclick="form_post(evt)">      <rect width="120" height="50" x="100" y="100"          style="stroke:black; fill:#8470ff;"></rect>      <text x="100" y="150" text-anchor="middle"></text>      <text x="130" y="120">Restore</text>      <text x="135" y="140">View</text>    </g> 

Note that the onclick method name, form_post, is determined from the button control's parent form component:

    public void encodeBegin(FacesContext context,       UIComponent component)           throws IOException {    ...        UIComponent root = context.getViewRoot();        UIComponent myForm = component;        while (!(myForm instanceof UIForm) && root != myForm) {            myForm = myForm.getParent();        }        String formMethodName = myForm.getClientId(context) +             "_post(evt)";        writer.writeAttribute(            "onclick", formMethodName, "onclick");       

The FormRenderer.encodeEnd() method writes out page state and the ending group element for the form control:

    <text name="javax.faces.ViewState"     id="javax.faces.ViewState" value="_id4:_id6"        visibility="hidden">_id4:_id6</text>     <text name="javax.faces.RenderKitId"          id="javax.faces.RenderKitId" value="SVG"          visibility="hidden">SVG</text>   </g> 

It also produces the JavaScript function that will collect the post data and send the request:

    <script><![CDATA[    function form_post(evt) {      var control = evt.target;      var form = getForm(control);      var postData = getPostData(form, control);      var url = "/jsf-renderkits/render/svg.jsp";      sendRequest(url, postData);    }    //]]>    </script> 

The mapping is such that the request goes to the JSF controller.

The functions getForm, getPostData and sendRequest are all defined in the http-svg.es ECMAScript file. (You can find the http-svg.es file in the renderkits\src\script directory of the example JSF application.) For example, here's part of the definition of the getPostData function:

    function getPostData(form, control) {                var formValues = new Array();        formValues[0] = new Object();        formValues[0].id = control.parentNode.id;        formValues[0].value = control.parentNode.id;        formValues[1] = new Object();        formValues[1].id = form.id;        formValues[1].value = form.id;        ...                var postData = "";        for (var i=0; i<formValues.length; i++) {            if (formValues[i].id == "javax.faces.ViewState") {                var re = new RegExp("\\+", "g");                var val = formValues[i].value;                formValues[i].value = val.replace(re, "\%2B");            }            postData += formValues[i].id + "=" +                 formValues[i].value;            if (i != formValues.length-1) {                postData += "&";            }        }        return postData;    } 

Notice that getPostData sends the hidden field javax.faces.ViewState. This is how JSF determines that the request is a post back.

Processing the Request

When the request is sent to JSF, it goes through the normal JSF life cycle processing steps. However, there is a special JSF phase listener registered to execute after the invoke applications phase (that is, just before the render response phase). If the request is an AJAX request (denoted by the XML-HTTP string in the request header), this phase listener will get the view identifier of the view that will be rendered next. The phase listener then puts the view identifier in the response header.

    public class ResponsePhaseListener implements PhaseListener {        private static final String XML_HTTP = "XML-HTTP";        private static final String VIEW_URI = "VIEW-URI";    ...        public void afterPhase(PhaseEvent event) {            // Disregard requests that are not XMLHttpRequest(s)            Map<String, String> requestHeaderMap =                  event.getFacesContext().getExternalContext().                        getRequestHeaderMap();            if (requestHeaderMap.get(XML_HTTP) == null) {                return;            }            // If we're dealing with an XMLHttpRequest...            // Get the URI and stuff it in the response header.            FacesContext context = event.getFacesContext();            String viewId = context.getViewRoot().getViewId();            String actionURL =                 context.getApplication().getViewHandler()                  .getActionURL(context, viewId);            HttpServletResponse response = (HttpServletResponse)                 context.getExternalContext().getResponse();            response.setHeader("Cache-Control", "no-cache");            response.setHeader(VIEW_URI, actionURL);        }    ...    } 

The processResponse method gets the view identifier from the response header. The client then loads that location. The processResponse method is defined in the http-svg.es ECMAScript file.

    function processResponse() {        var request = getXMLHttpRequest();        if (request.readyState == 4) {            if (request.status == 200) {                var action =                     request.getResponseHeader("VIEW-URI");                window.location.href = action;                return;            }       }    } 

For more information using render kits in JSF, see the technical article Creating and Using a Custom Render Kit.

Running the Sample Code

A sample package accompanies this tip that demonstrates the techniques covered in the tip. You can deploy the sample package on any web container that supports the Servlet 2.5 API, JavaServer Pages (JSP) Technology 2.1, and JSF 1.2. You will also need to use JDK 5. For the client (browser) you need to use a Mozilla browser with built-in SVG support, such as Firefox 1.5.

To install and run the sample:

  1. If you haven't already done so, download GlassFish from the GlassFish Community Downloads page. GlassFish supports Servlet 2.5 and the JSP 2.1 "out of the box".

  2. Download the sample package for the tip and extract its contents. You should now see the newly extracted directory as <sample_install_dir>/renderkits, where <sample_install_dir> is the directory in which you installed the sample package. For example, if you extracted the contents to C:\ on a Windows machine, then your newly created directory should be at C:\renderkits. The renderkits directory contains the web archive, renderkits.war, for the application, and the subdirectories src and web for viewing source.

  3. Start the GlassFish Application Server by entering the following command:

    <GF_install_dir>/bin/asadmin start-domain domain1

    where <GF_install_dir> is the directory in which you installed GlassFish.

  4. Deploy the sample by copying <sample_install_dir>/renderkits/jsf-renderkits.war to <GF_install_dir>/domains/domain1/autodeploy

  5. Open your browser to the URL:
    http://localhost:8080/jsf-renderkits/. As mentioned previously, you need to use a Mozilla browser, such as Firefox 1.5, with built-in SVG support.

About the Author

Roger Kitain is the JavaServer Faces co-specification lead. He has been extensively involved with server-side web technologies and products since 1997. Roger started working on JavaServer Faces technology in 2001, as a member of the reference implementation team. He has experience with Servlet and JSP technologies. Most recently, Roger has been involved with different rendering technologies for JSF.

Back to Top

ACCESSING A SECURE ENTERPRISE BEAN FROM A JAVA CLIENT OR THROUGH JAVA WEB START TECHNOLOGY
 
by Sreenivas Munnangi

This Tech Tip shows you how to access a secure Enterprise JavaBeans component (also called an "enterprise bean") from a standalone Java client and from a Java EE application client that uses Java Web Start technology. The tip presents examples that show these clients accessing a secure Management Enterprise JavaBean (MEJB) that conforms to the J2EE Management specification, JSR 77. The J2EE Management specification provides a standard management model for exposing and accessing management information, operations, and attributes for J2EE components. An MEJB provides interoperable remote access to the model from any standard J2EE application.

The tip assumes that you are using either the Sun Java System Application Server 8.x or a GlassFish build. You can download Sun Java Application Server 8.2 or 8.1 as part of the J2EE 1.4 SDK from the J2EE 1.4 Downloads page. GlassFish is an open source Java EE-based application server. You can download GlassFish from the GlassFish Community Downloads page.

Securing an Enterprise Bean

Security for J2EE application components such as enterprise beans is provided by their containers. A container provides two kinds of security: declarative and programmatic. Declarative security expresses an application's security structure, including security roles, access control, and authentication requirements, in a form external to the application (that is, in a deployment descriptor). Programmatic security is embedded in an application and is used to make security decisions. Programmatic security is useful when declarative security alone is not sufficient to express the security model of an application.

The mechanics of providing declarative security for these resources involve mapping in a deployment descriptor individual user identities or groups of user identities to a role, that is, an abstract name for the permission to access a particular set of resources in an application.

For example, the following elements in the Sun Java Application Server deployment descriptor, sun-application.xml, maps the group name "asadmin" to the security role "admin-role":

    <security-role-mapping>      <role-name>admin-role</role-name>      <group-name>asadmin</group-name>    </security-role-mapping>   

In addition, application servers such as Sun Java System Application Server 8.x or GlassFish provide a way to associate groups while creating a principal (that is, an individual user identity that can be authenticated). This is done through the asadmin create-file-user command (whose syntax is as follows):

    asadmin create-file-user --port <port> --host <host>     --user <user-id> --passwordfile <passwordfile-location>     --authrealmname admin-realm --groups <admingrp>     <realm-user-id> 

After the mapping is in place, the container can determine if a user has the needed permission to access a protected resource such as a secure enterprise bean.

For standalone clients, declarative security is insufficient to communicate with a secure enterprise bean. Instead you need to provide programmatic security.

Programmatic Security for a Secure Enterprise Bean

Programmatic security for a standalone client requires an API that provides programmatic login for the client. The Sun Java System Application Server 8.x and GlassFish provide this API through the class com.sun.appserv.security.ProgrammaticLogin. This class exposes relevant methods to perform programmatic login operations. The examples for this tip use the following ProgrammaticLogin method to access an MEJB:

    public Boolean login(String user, String password);  

The login() method supplies a username and password. This information is used to attempt to login to the default authentication realm (that is, the collection of users and groups that are controlled by the same authentication policy). If the authentication succeeds, that is, the identity of the user is verified, a security context is established representing the user. This allows applications to programmatically handle authentication.

Let's look at an example of programmatic security for a secure enterprise bean. Accompanying this tip is a package that contains the code for a standalone client that accesses a secure MEJB. Here's a code snippet taken from the standalone client code:

    ProgrammaticLogin pm = new ProgrammaticLogin();     pm.login(userId, password);    Context initial = new InitialContext();    Object objref = initial.lookup("ejb/mgmt/MEJB");    ManagementHome home =        (ManagementHome)PortableRemoteObject.narrow(            objref, ManagementHome.class);    Management mejb = home.create();    String domain = mejb.getDefaultDomain(); 

The code first instantiates ProgrammaticLogin and then accesses its login() method, providing the userId and password. The login() method caches this information on the client side until an enterprise bean method is called from the client. The code then does the processing for access to the MEJB. It instantiates the InitialContext, and then looks up the ManagementHome object by specifying the JNDI name of MEJB home object, ejb/mgmt/MEJB.

You might ask how are the user's credentials processed? The user credentials are passed to the server when the client calls the enterprise bean's method. The method call is intercepted by the IIOP/ORB infrastructure and the credentials are stored in the security context. If the method being invoked needs permission, the EJB container retrieves the user credentials from the security context and validates them. If the credentials are not valid, the method throws a security exception.

After the lookup and narrow methods succeed, a reference to the Management object is created. This is done by calling the ManagementHome's create() method -- this is part of the standard enterprise bean invocation process. This is further described in the section Developing Clients Without the ACC in the Sun Java Application Server Platform Edition 8.1 Developer's Guide.

Now it's time to try the sample applications. The samples require you to have access to ant or asant that is included in GlassFish and Sun Java Application Server 8.1 or 8.2.

Running the Standalone Client Example

The standalone client works directly with a predeployed system application. To install and run the standalone client example:

  1. Ensure that either Sun Java System Application Server 8.2 or GlassFish is installed. These instructions use GlassFish, which you can download from the GlassFish Community Downloads page.

  2. Download the sample package for the tip and extract its contents. You should now see the newly extracted directory as <sample_install_dir>/stand_alone_client, where <sample_install_dir> is the directory in which you installed the sample package. For example, if you extracted he contents to C:\ on a Windows machine, then your newly created directory should be at C:\stand_alone_client. The stand_alone_client directory contains the source code for the client, MEJBClient.java, a build file, build.xml, and an output file, output.txt.

  3. Start the GlassFish Application Server by entering the following command:

          <GF_install_dir>/bin/asadmin start-domain domain1 
    where <GF_install_dir> is the directory in which you installed GlassFish.

  4. Modify the <user defined properties> section of the build.xml file as appropriate for your application server installation. You don't have to edit any other part of build.xml.

  5. Create a default realm user using the asadmin command line utility as follows (the command is shown on multiple lines for formatting purposes):

         <GF_install_dir>/bin/asadmin create-file-user      --host <host-name> --port <admin-port-number>      --user <admin-user> --passwordfile <admin-password-file-path>      --groups <security-role-mapping-group-name> <realm.user.id>  
    You will need to create a password file that includes the following lines:

          AS_ADMIN_PASSWORD=<admin-password>      AS_ADMIN_USERPASSWORD=<realm.user.password> 
    and pass this file with the --passwordfile option.

    Make sure that the values for realm.user.id and realm.user.password match the values given in build.xml, and the value for security-role-mapping-group-name matches the value given in sun-application.xml as described earlier in the tip. Substitute other values appropriately before running the command.

    Use the asadmin command 'list-file-users' to check that you successfully created the default realm user. For further information about the asadmin command, enter asadmin help on the command line.

  6. Compile and run MEJBClient.java.
           > cd stand_alone_client       > ant run 
    You should see output similar to the following.

           run:         [java] Jan 17, 2006 2:48:49 PM com.sun.corba.ee.spi.         logging.LogWrapperBase doLog         [java] INFO: "IOP00710299: (INTERNAL) Successfully          created IIOP listener on the specified host/port:          all interfaces/52185"         [java] ***Got the MEJB!!         [java] ***MEJB default domain = DefaultDomain         ...         BUILD SUCCESSFUL 
    The content of the output.txt file contains the complete output.

Running the Java Web Start Technology Example

This example uses a Java EE application client that will be deployed to the application server. As is the case for the previous example, this example uses GlassFish. This example has been tested to work with JDK 5.0 or JRE 5.0 only.

To install and run the example:

  1. Download the sample archive.

  2. Deploy the application client using the deploy command:
           <GF_install_dir>/bin/asadmin deploy --host <host-name>        --port <admin-port-number> --user <admin-user>        --passwordfile <admin-password-file-path>        ttfeb2006acc-mejbClient.jar
  3. Open your application server log (for example, <GF_install_dir>/domains/domain1/log/server.txt). Somewhere in the log you should see a line like the following:

           [#|2006-01-17T15:10:21.112-0800|... Java Web Start        services started for stand-alone app client ...        name=acc-mejbClient, context root=/acc-mejbClient,        module name=|#]  
    The URL for accessing the application client using Java Web Start is comprised of the default GlassFish instance URL and the context root (which is the "Name=" value in the line shown above). So, for a default instance Glassfish URL of http://8080 and a context root of acc-mejbClient, the URL for accessing the application client using Java Web Start is http://localhost:8080/acc-mejbClient.

  4. This example displays output in the Java Console. To see the output, you need to configure Java Web Start to show the Java Console. To configure the Java Console option, first determine the location of Java Web Start (this is usually <jre-install-dir>/bin/javaws or <jre-install-dir>/bin/jws). Then invoke Java Web Start and turn on the 'show console' option. Here is how to determine the location of Java Web Start based on the browser type and the operating system:

    • Internet Explorer and FireFox on Windows:
      • Click on <start> <My Computer>.
      • In the 'My Computer' window, select the menu item <Tools> then <Folder Options>.
      • In the 'Folder Options' window, select the <File Types> tab.
      • Select the item with the extension 'JNLP'.
      • Click <Advanced> <Edit> and verify that the 'Application used to perform action' is correct, or change it to the correct one, and save the changes.

    • Netscape on Windows/Solaris:
      • Invoke the Netscape browser.
      • Select the menu item <Edit> then <Preferences>.
      • Expand <Navigator> node and select <Helper Applications>. You should see a list of File Types on the right.
      • Select application/x-java-jnlp-file.
      • Click <Edit>. Make the appropriate change and save it.

      Invoke Java Web Start in a command window using the Java Web Start location determined above. This brings up 'the 'Java Application Cache Viewer' window.

      Then:

      • In the 'Java Application Cache Viewer' window select the menu item <Edit>, then <Preferences>. This should display 'Java Control Panel'.
      • Select the <Advanced Tab>.
      • Expand <Java Console> and select <Show Console>. Click the <OK> button.

      You can exit Java Web Start by selecting the menu item <File>, then <Exit>.

  5. Open a web browser and enter the URL determined in step 3. This should launch Java Web Start. You should see prompts for a userID and password. After you respond to the prompts, the application client should display output similar to the output in the standalone client example.

About the Author

Sreenivas Munnangi is a senior member of the Sun Java Application Server Administration and Management team. He has worked in the J2EE group for the last three years. He was a key contributor to the Application Server Enterprise Edition design and implementation. His earlier experience was in the areas of eCommerce applications, web applications, and N-tier application architecture.

Back to Top

GET THE PREVIEW OF THE JAVA EE 5 SDK!
 

On February 21, 2006, Sun announced availability of the preview of Java EE 5 SDK, which includes Application Server Platform Edition 9 beta. This release is a simultaneous release with NetBeans Enterprise Pack 5.5, providing developers with the next generation Java platform and tools for building and deploying enterprise Java and Service-Oriented Architecture (SOA)-ready applications to solve business challenges. Sun led the development of these breakthrough technologies, incorporating key contributions from the open source GlassFish Project and NetBeans.org communities to create an innovative, robust, and scalable development platform that is ideal for enterprise Web 2.0 development.

Back to Top

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
If you would like a reply to your comment, please submit your email address:
Note: We may not respond to all submitted comments.
Comments? Send your feedback on the Tech Tips: http://developers.sun.com/contact/feedback.jsp?category=newslet

Subscribe to the following newsletters for the latest information about technologies and products in other Java platforms:
  • Core Java Technologies Tech Tips. Get tips on using core Java technologies and APIs, such as those in the Java 2 Platform, Standard Edition (J2SE).
  • Wireless Developer Tech Tips. Get tips on using wireless Java technologies and APIs, such as those in the Java 2 Platform, Micro Edition (J2ME).
You can subscribe to these and other Java technology developer newsletters or manage your current newsletter subscriptions on the Sun Developer Network Subscriptions page

IMPORTANT: Please read our Terms of Use, Privacy, and Licensing policies:
http://www.sun.com/share/text/termsofuse.html
http://www.sun.com/privacy/
http://developer.java.sun.com/berkeley_license.html

ARCHIVES: You'll find the Enterprise Java Technologies Tech Tips archives at:
http://java.sun.com/developer/EJTechTips/index.html

© 2006 Sun Microsystems, Inc. All Rights Reserved. For information on Sun's trademarks see: http://sun.com/suntrademarks
Java, J2EE, J2SE, J2ME, and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.



Please unsubscribe me from this newsletter.


 
News, Articles, events from all over the world

My Photo
Name:
Location: India

Born on shraavana shudha chauthi of dundubhi naama samvaswara, Im kiran alias kini alias kiri bought up by loving parents. Being from agricultural family I have learnt plowing, carting but never learnt climbing trees. Now away from home I have lost touch with the agricultural skills.

ARCHIVES
January 2006 / February 2006 / March 2006 / April 2006 / May 2006 / June 2006 / July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / April 2007 / May 2007 / June 2007 / July 2007 / August 2007 / September 2007 / October 2007 / November 2007 / December 2007 / January 2008 / February 2008 / March 2008 / April 2008 / May 2008 / June 2008 / July 2008 / August 2008 / September 2008 / October 2008 / November 2008 / December 2008 / January 2009 / February 2009 / March 2009 / April 2009 /


Powered by Blogger