webdesign

http://www.noupe.com/css/47-excellent-ajax-css-forms.html
http://demos.99points.info/animated_form/
http://www.htmldrive.net/items/show/1087/Cool-Dropdown-Login-Form-with-jQuery



"JSF "


JSF

1 )   What is JSF ?

Ans)
JavaServer Faces (JSF) is a Java-based Web application framework intended to
simplify development integration of web-based user interfaces.
JSF is a request-driven MVC web framework for constructing user interfaces using
components. As a display technology, JSF 2 uses Facelets. JSF 1.x uses JavaServer
Pages (JSP) for its displaytechnology.
One of the very imporant features of JSF is it's "A server-side event model"
A server-side event model : For dispatching events and attaching listeners to
core system functionality, such as "Before Render Response" or "After Validation"



2 )   What are the LifeCycle Phases of JSF page ?

Ans)

  • LifeCycle Phases of JSF page
    Sample Img 2
The six phases of the JSF application lifecycle are as follows (note the event processing
at each phase):
1.Restore view
2.Apply request values; process events
3.Process validations; process events
4.Update model values; process events
5.Invoke application; process events
6.Render response

Phase 1: Restore view
In the first phase of the JSF lifecycle -- restore view -- a request comes through the FacesServlet
controller. The controller examines the request and extracts the view ID, which is determined by the name of the JSP page.
Phase 2: Apply request values
The purpose of the apply request values phase is for each component to retrieve its current
state. The components must first be retrieved or created from the FacesContext object,
followed by their values. Component values are typically retrieved from the request parameters,
 although they can also be retrieved from cookies or headers.

Phase 3: Process validation
The first event handling of the lifecycle takes place after the apply request values phase.
At this stage, each component will have its values validated against the application's
validation rules. The validation rules can be pre-defined (shipped with JSF) or defined by the developer

Phase 4: Update model values
The fourth phase of the JSF application lifecycle -- update model values -- updates the actual
values of the server-side model -- namely, by updating the properties of your backing beans
(also known as managed beans).

Phase 5: Invoke application
At the fifth phase of the lifecycle -- invoke application -- the JSF controller invokes the
application to handle Form submissions.
Phase 6: Render response
In the sixth phase of the lifecycle -- render response -- you display the view with all
of its components in their current state.



3 )   JSF Tags for html components ?

Ans)
Tag Libs to be included :
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
HTML form:
<h:form>
... other JavaServer Faces tags and other content...
</h:form>
Hyper Link:
<h:commandLink id="check"
  ...
  rendered="#{cart.numberOfItems > 0}">
  <h:outputText
    value="#{bundle.CartCheck}"/>
</h:commandLink>
Table :
<h:dataTable id="items"
  ...
  value="#{cart.items}"
  var="item">
  ...
  <h:column>
    <f:facet name="header">
      <h:outputText value="#{bundle.ItemQuantity}"/>
    </f:facet>
    <h:inputText
      ...
      value="#{item.quantity}">
      <f:validateLongRange minimum="1"/>
    </h:inputText>
  </h:column>
  ...
</h:dataTable>



4 )   Sample "faces-config.xml" ?

Ans)

"faces-config" is going to have two high level Elements "navigation-rule" and  "managed-bean"

<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
  <navigation-rule>
   <from-view-id>/pages/inputname.jsp</from-view-id>
    <navigation-case>
     <from-outcome>yourgreeting</from-outcome>
     <to-view-id>/pages/greeting.jsp</to-view-id>
   </navigation-case>
  </navigation-rule>
  <managed-bean>

    <managed-bean-name>personBean</managed-bean-name>
    <managed-bean-class>PersonBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
</faces-config>



5 )   Sample Event Handling in JSF ?

Ans)
Event Handling :
<h:selectOneRadio id="category"
  value="#{CDManagerBean.cd.category}"
  immediate="true"
  onclick="submit()"
  valueChangeListener="#{CDManagerBean.categorySelected}">
    <f:selectItems value="#{CDManagerBean.categories}"/>
</h:selectOneRadio>
Event Handling Method :
public void categorySelected(ValueChangeEvent event) {
    subCategoryList.setRendered(true);
    String value = (String) event.getNewValue();
    if (value != null) {
        this.subCategories = this.getSubcategoriesList(value);
    }
    FacesContext context = FacesContext.getCurrentInstance();
    context.renderResponse();
}
Managed Bean :
<managed-bean>
  <description>The "backing file"
    bean that backs up the CD application</description>
  <managed-bean-name>CDManagerBean</managed-bean-name>
  <managed-bean-class>
    com.arcmind.jsfquickstart.controller.StoreController
      </managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
</managed-bean>



6 )   How to add "FacesServlet" to Web.xml for a JSF application ?

Ans)
Make for JSF has different "url-pattern" other than JSP.
<!-- JSF -->
 <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jf</param-value>
 </context-param>

 <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
 </servlet>