ArticlesTutorialsInterview Questions & AnswersCertificationsFree Books & Sample ChaptersTechnical Discussions  Your Account | Advertise with us | Feedback |
Few pages of this site are under construction and we are constantly trying to improve it. If you have any suggestions or ideas about how to improve the site, please Let us know.
A first look at Shale Framework - Get started with Shale

A first look at Shale Framework
Get started with Shale    -by Anand K Reddy ,DevelopersBook.com, 06/02/2007

page  3 of 5
Framework Config Files

Now that we have our dependencies in place and a webapp that is configured to use Shale, we'll add some blank configuration files under helloworld/WEB-INF that Shale and JSF will need in order to properly initialize themselves.

The digest-config.xml file is required for nightly build of Shale - the default application filter won't initialize without it.

dialog-config.xml

!DOCTYPE dialogs PUBLIC

  "-//Apache Software Foundation//DTD Shale Dialog Configuration 1.0//EN"

  "http://struts.apache.org/dtds/shale-dialog-config_1_0.dtd">

 <dialogs>

 </dialogs>

chain-config.xml

<?xml version="1.0" encoding="UTF-8"?>

 <catalogs>

            <catalog name="shale">

      <!-- Disallow direct access to JSP and JSFP resources -->

      <command      className="org.apache.shale.application.ContextRelativePathFilter"

                     includes="\S*\.xml,\S*\.faces,\S*\.phpl,\S*\.gif,\S*\.jpg,/index\.jsp"

                     excludes="\S*\.jsp,\S*\.jspf"/>                                                                           

            </catalog>

</catalogs>

We only define one rule in our Chain's shale catalog, and that's to disallow direct access to our JSP files. This is because we want to force our users to access the site through the JSF Servlet. We'll also need a faces-config.xml file, but we'll revisit that in next step.

Web App

I know that seems like a lot of work to have gotten nowhere so far; if you ever worked with Struts from scratch I think you'd have thought the same thing about that. We're getting there though, it's finally time to write some code and make some JSPs.

First we'll create a simple NameBean class:

package com.developersBook.jsfApp;

public class NameBean {

            private String name;

            public void setName( final String name )

            {                     

            this.name = name;        

            }

                  public String getName()

            {

                     return this.name;

            }

}

Then we'll create some JSPs. One will prompt for your name, and populate the name bean with the value you enter. The others will say ‘Hello’ or ‘Bye’, depending on which action the user chooses.

welcome.jsp

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

 <html>

            <head>

                        <title>Hello World!</title>

            </head>

            <body>

                <f:view>

                         <h1><h:outputText value="Welcome………"/></h1>

                         <h:form id="helloform">

                         <h:outputText value="Enter your name:"/>

                         <h:inputText value="#{nameBean.name}"/>

                         <h:commandButton action="hello" value="Say Hello"/>

                         <h:commandButton action="bye" value="Say Bye"/>

                          </h:form>

                </f:view>

            </body>

</html>

  Continued.....

1|  | 2| 3  |  4  |  5  | Articles Home
Test
About Us | Our Mission | Terms of use | Author Terms |    Search        | Contact Us | Advertise With Us | Link to Us | Sitemap
Copyright © 2016 developersBOOK.COM. All rights reserved.