

|
|
Home >> Miscellaneous
Extending some of the JSF-based tag libraries while using an already
hosted Page on this web site -
Referring to the earlier example page
If you have come to this Page for the first time, then I would request you
to refer the example initially posted in this web site some time back,
and the list as shown above. As this example is just an extension of that
example only and I have tried to show some more Tags from JSF distribution,
like for example selectManyCheckbox, selectBooleanCheckbox, selectManyListbox,
selectOneListbox from the JSF HTML related tags and selectItems from JSF core
tag libraries.
I have used JSTL tag libraries in the preview JSP page from this example, and
the purpose is to use some of the looping for each functionality and
corresponding out tag from the JSTL tag libraries for printing resulting
values from the collection/list/arrays of values from the Managed bean.
|
|  |
|
Basically I have changed three files like index.jsp, preview.jsp and
instance of ButtonEventCapture class file as managed bean.
index.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="sampleHtml" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="sampleCore" %>
<html>
<body>
<sampleCore:view locale="en_US">
<sampleCore:loadBundle basename="sample" var="s"/>
<h4><sampleHtml:outputText value="#{s.title_text}"/></h4>
<sampleHtml:messages layout="table"/>
<sampleHtml:form>
<table>
<tr><td><sampleHtml:outputText value="#{s.name_text}"/></td>
<td><sampleHtml:inputText id="txtName" value="#{SampleMGMTBean.txtName}"/></td></tr>
<tr><td><sampleHtml:outputText value="#{s.pass_text}"/></td>
<td><sampleHtml:inputSecret value="#{SampleMGMTBean.txtPass}"/></td></tr>
</table>
<sampleHtml:selectManyCheckbox id="manyChkBoxes" value="#{SampleMGMTBean.selectedData}">
<sampleCore:selectItems value="#{SampleMGMTBean.tableData}"/>
</sampleHtml:selectManyCheckbox>
<br>
<sampleHtml:selectBooleanCheckbox id="test" value="#{SampleMGMTBean.chkBox}">
selectBooleanCheckbox :
</sampleHtml:selectBooleanCheckbox>
<br>
<sampleHtml:selectManyListbox id="manyListBoxes" value="#{SampleMGMTBean.selectedList}">
selectManyListbox :
<sampleCore:selectItems value="#{SampleMGMTBean.tableData}"/>
</sampleHtml:selectManyListbox>
<br>
<sampleHtml:selectOneListbox id="oneList" value="#{SampleMGMTBean.selectedListData}" size="1">
selectOneListbox :
<sampleCore:selectItems value="#{SampleMGMTBean.tableData}"/>
</sampleHtml:selectOneListbox>
<table>
<tr><td><sampleHtml:commandButton value="Submit"
action="#{SampleMGMTBean.submitButton}"/></td>
<td><sampleHtml:commandButton value="Cancel"
action="#{SampleMGMTBean.cancelButton}"/></td></tr>
</table>
</sampleHtml:form>
</sampleCore:view>
</body>
</html>
|
preview.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="sampleHtml" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="sampleCore" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="jstlCore" %>
<html>
<body>
<h4>Preview</h4>
<sampleCore:view>
<sampleHtml:form>
<table>
<tr><td>Name :</td><td><sampleHtml:outputText value="#{SampleMGMTBean.txtName}"/></td></tr>
<tr><td>Pass :</td><td><sampleHtml:outputText value="#{SampleMGMTBean.txtPass}"/></td></tr>
<tr><td valign="top">selectManyCheckbox :</td><td bgcolor="#aaee22">
<jstlCore:forEach var="si" items="${SampleMGMTBean.selectedData}">
<jstlCore:out value="${si}"/><br>
</jstlCore:forEach>
</td></tr>
<tr><td valign="top">selectBooleanCheckbox :</td><td bgcolor="#aabbee">
<jstlCore:out value="${SampleMGMTBean.chkBox}"/>
</td></tr>
<tr><td valign="top">selectManyListbox :</td><td bgcolor="#22ee22">
<jstlCore:forEach var="si" items="${SampleMGMTBean.selectedList}">
<jstlCore:out value="${si}"/><br>
</jstlCore:forEach>
</td></tr>
<tr><td valign="top">selectOneListbox :</td><td bgcolor="#aaeeff">
<jstlCore:out value="${SampleMGMTBean.selectedListData}"/>
</td></tr>
</table>
</sampleHtml:form>
</sampleCore:view>
</body>
</html>
|
By now you might have noticed that while using JSF tags, in value attribute I
have used expression using an enclosing #{} and while using JSTL tag library
I have used an enclosing ${} for those expressions.
Following Managed bean is a simple and having hard coded values for easy and
faster example preparation techniques covered. This class is a POJO with
minimum required instance variables and method definitions, along with some
of the actions implemented.
ButtonEventCapture.java
package sample;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
import javax.faces.validator.Validator;
public class ButtonEventCapture
{
public ButtonEventCapture()
{
tableData = new SelectItem[]{new SelectItem("zero","zero"),
new SelectItem("one","one"),
new SelectItem("two","two"),
new SelectItem("three","three"),
new SelectItem("four","four"),
new SelectItem("five","five"),
new SelectItem("six","six"),
new SelectItem("seven","seven"),
new SelectItem("eight","eight")};
selectedData = new String[2];
selectedData[0] = "two";
selectedData[1] = "eight";
chkBox = false;
chkBoxLabel="Male";
}
public void setTxtName(String txtName)
{
this.txtName = txtName;
}
public String getTxtName()
{
return txtName;
}
public void setTxtPass(String txtPass)
{
this.txtPass = txtPass;
}
public String getTxtPass()
{
return txtPass;
}
public String submitButton()
{
//do something useful here.
return "preview";
}
public String cancelButton()
{
System.out.println("Cancel button is clicked...");
return null;
}
public SelectItem[] getTableData() {
return tableData;
}
public void setTableData(SelectItem[] objs) {
System.out.println(objs.length +" "+objs[0]);
}
public void setSelectedData(String[] arg) {
System.out.println(arg.length + " " +arg[0]);
selectedData = arg;
}
public String[] getSelectedData() {
return selectedData;
}
public void setSelectedList(String[] arg) {
System.out.println(arg.length + " " +arg[0]);
selectedList = arg;
}
public String[] getSelectedList() {
return selectedList;
}
public void setSelectedListData(String data) {
selectedListData = data;
}
public String getSelectedListData() {
return selectedListData;
}
public void setChkBox(boolean arg) {
System.out.println(arg);
chkBox = arg;
}
public boolean getChkBox() {
return chkBox;
}
public void setChkBoxLabel(String arg) {
System.out.println(arg);
}
public String getChkBoxLabel() {
return chkBoxLabel;
}
String txtName = "";;
String txtPass = "";
SelectItem[] tableData;
boolean chkBox;
String chkBoxLabel;
String[] selectedData;
String[] selectedList;
String selectedListData;
}
|
Mostly I have used array of String and SelectItem, instead one can use
List as the type for these variables like tableData, selectedData, selectedList.
This JSF-based example has two screens, the first one is the index page and
the second one is the preview of the user inputted data from the index Page.
In order to make this example run, one may require all other files such as
web.xml, preview.jsp, faces-config.xml files from the initial example Page
from this web site ( Refering to the earlier example page)
If anything missed out , please let me know at
techienjoy at yahoo . com
| Android Tab View Example : |
Example on Android Tab View
explained with a very simple scenario
and appropriate screens captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
| Android ListView Example : |
Example on Android ListView and
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
| Google GWT Example : |
Example using GWT and some design patterns and various
ways of implementing this example.
|
|
| Android Examples : |
List of ANDROid examples
with source code and output
screens captured and shown.
|
|
|
|
|
|
|
|
|
| Android ListView Example : |
Example on Android List View
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android Sensors Example : |
Example on Android Sensors Listed and
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
| Android ListView Example : |
Example on Android ListView
explained with a very simple scenario
whereby showing folder and files with
structure and appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
| Android Gallery Example : |
Example on Android Gallery View
explained with a very simple scenario
and appropriate screens captured and shown.
|
|
References :
Tags: TabHost and TabActivity Example on Android Platform
Tags: ListView Example on Android Platform
Tags: android sensors list
Tags: android listview example
Tags: android imageview example
Tags: Android example download any file sourcecode
Tags: android expandable list dynamically created example
Tags: android expandable list example
Tags: Android Gallery surfaceviews spinner
Tags: Android example download any file sourcecode
Tags: Android Layout Example
Tags: Android Text To Speech Example
Tags: DOJO Example Dialog
Tags: DOJO Example Tree Widget
Tags: different logger file log4j
Tags: JDBC Transaction isolation
Tags: event handling java code
Tags: example quartz scheduler
Tags: example tag library web application
Tags: Flex
Tags: index
Tags: inmemory image creation java awt
Tags: JSF Example Main
Tags: JSF Example Tags CheckBoxes
Tags: JSF Example Tags dataTable
Tags: JSF Example Tags SelectBoxes
Tags: JSF Example Tags Walkthrough
Tags: JSF Example Validation
Tags: JSF Resource Bundle
Tags: log4j example 1
Tags: log4j example
Tags: Miscellaneous
Tags: Mule ESB File Transport
Tags: Mule ESB JMS Transport
Tags: stream download batch
Tags: sychronized block wait notify
Tags: thread wait notify example
Tags: using apache commons log
Tags: web load test
Tags: Wizard Framework Idea Java
DISCLAIMER :
The content provided in this page is not warranted and/or guaranteed by techienjoy.com.
techienjoy.com is not liable for any negative consequences that may result/arise from
implementing directly/indirectly any information covered in these pages/articles/tutorials.
All contents of this site is/are written and provided on an "AS IS" basis,
without WARRANTIES or conditions of any kind, either express or implied, including, without
limitation, merchantability, or fitness for a particular purpose. You are solely responsible
for determining the appropriateness of using or refering this and assume any risks associated
with this.
In spite of all precautions taken to avoid any typo in these pages, there might be some
issues like grammatical mistakes and typos being observed in these pages, techienjoy.com
extends sincerest apologies to all our visitors for the same.
|
| 

|