Showing posts with label Facelets. Show all posts
Showing posts with label Facelets. Show all posts

Sunday, February 9, 2014

No   in xhtml

In html or jsp, we use " " to make a space,
But in xhtml, " " is not taking any effect.

To make a space in xhtml, should use  

for more information about Character Entities Reference, please go here.


Done!!

Tuesday, September 3, 2013

How to create side menu layout with p:menu

The objective of this post is to create side menu layout as below.

1. create a side menu template
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:ui="http://java.sun.com/jsf/facelets"> 

<h:head />
<h:body>
 <h:form>
        <table>
            <tr>
                <td><ui:insert name="sidemenu" /></td>
                <td><ui:insert name="content" /></td>
            </tr>
        </table>
  </h:form>
</h:body>
</html>

Thursday, June 6, 2013

Authorization in JSF with Facelets View Handler

According to wikipedia, authorization is the function of specifying access rights to resources.
Authorization is important to protect sensitive against different users.

The simplest way is to provide the access right to the targeted fields/components directly
for readOnly access,
<h:outputText id="authorizedId" value="#{bean.authorizedValue}" readonly="#{bean.authorizedReadonly}" />

for viewable access,
<h:outputText id="authorizedId" value="#{bean.authorizedValue}" disabled="#{bean.authorizedDisabled}" />

but the above solution is NOT feasible if there are many pages and fields/components to be authorized;
NOT flexible, if there are access right changes, re-coding is required.

Another feasible way is through FaceletsViewHandler.
In JSF with Facelets view handling, we can actually place all the authorization controls to the FaceletsViewHandler as the control central.

Thursday, April 11, 2013

How to create Credit Card Validator with Facelets

This post shows how to build a custom JSF regex validator to validate Credit Card number with Facelets.

There are different types of Credit Cards, the regex used to validate different types of Credit Card are vary with the types of Credit Card.
Visa ^4[0-9]{12}(?:[0-9]{3})?$
Master Card ^5[1-5][0-9]{14}$
American Express ^3[47][0-9]{13}$
Diners Club ^3(?:0[0-5]|[68][0-9])[0-9]{11}$

For more information about Credit Card Regex, please refer here.
so now let's start to build the Credit Card validator.

Tuesday, April 9, 2013

Easy JSF Email validator with Facelets

This post shows how to build a custom JSF regex validator to validate email address with Facelets.
Building email validator with Facelets is very easy if compare to building email validator with JSF component classes.

Steps:
1. create the validateEmail.xhtml in folder <WebContent>/views/validator
    Regex here could be changed to any desired format.

<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html">
    <f:validateRegex
        pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />

</ui:composition>

Saturday, February 2, 2013

Dynamic Include

Dynamic include is a technique to programmatically include or toggle content into predefined position of a page. It can also uses to create wizard like application by toggle the contents of the wizard.

Benefits of dynamic include
- save bandwidth
- reduce page size
- reduce server memory with smaller component tree
- reduce page loading time

Disadvantages of dynamic include
- increase complexity

Example
- How to create layout with dynamic include
- dynamic include in Richfaces tabPanel
- How to create wizard with dynamic include in JSF2
- Dynamic include with richfaces popupPanel

LinkWithin

Related Posts Plugin for WordPress, Blogger...