Reader small image

You're reading from  PrimeFaces Beginner's Guide

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781783280698
Edition1st Edition
Languages
Right arrow
Author (1)
Siva Prasad Reddy Katamreddy
Siva Prasad Reddy Katamreddy
author image
Siva Prasad Reddy Katamreddy

K. Siva Prasad Reddy is a Senior Software Engineer living in Hyderabad, India, and having more than seven years of experience in developing enterprise applications with Java and JavaEE technologies. Siva is a Sun Certified Java Programmer and has a lot of experience in server-side technologies such as Java, JavaEE, Spring, Hibernate, MyBatis, JSF, PrimeFaces, and WebServices (SOAP/REST). Siva is also the author of Java Persistence with MyBatis 3, Packt Publishing. Siva normally shares the knowledge he has acquired on his blog at www.sivalabs.in. If you want to find out more about his work, you can follow him on Twitter (@sivalabs) and GitHub (https://github.com/sivaprasadreddy).
Read more about Siva Prasad Reddy Katamreddy

Right arrow

Time for action – reading formatted input using InputMask


Let's look at how to get phone number input in the 999-999-9999? (Ext:9999) format using the InputMask component:

  1. Create a form with a Phone input field to read a phone number in the 999-999-9999? (Ext:9999) format, by using the following code:

    <h:form id="form1">
        <p:panel header="My Account">  
            <h:panelGrid columns="2">  
                <p:outputLabel for="phone" value="Phone"/>
                <p:inputMask id="phone" value="#{userController.loginUser.phone}" mask="999-999-9999? (Ext:9999)" placeHolder="X"/>  
            </h:panelGrid>  
        </p:panel>  
    </h:form>

What just happened?

We have used the <p:inputMask> component to read a phone number in the 999-999-9999 format. To set the extension number as optional, we have mentioned the extension part after the ? symbol. As we have set the placeholder to X, when you put the cursor in the Phone input field, the mask is displayed as...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
PrimeFaces Beginner's Guide
Published in: Nov 2013Publisher: PacktISBN-13: 9781783280698

Author (1)

author image
Siva Prasad Reddy Katamreddy

K. Siva Prasad Reddy is a Senior Software Engineer living in Hyderabad, India, and having more than seven years of experience in developing enterprise applications with Java and JavaEE technologies. Siva is a Sun Certified Java Programmer and has a lot of experience in server-side technologies such as Java, JavaEE, Spring, Hibernate, MyBatis, JSF, PrimeFaces, and WebServices (SOAP/REST). Siva is also the author of Java Persistence with MyBatis 3, Packt Publishing. Siva normally shares the knowledge he has acquired on his blog at www.sivalabs.in. If you want to find out more about his work, you can follow him on Twitter (@sivalabs) and GitHub (https://github.com/sivaprasadreddy).
Read more about Siva Prasad Reddy Katamreddy