JSF 2 panelGrid example
In JSF , “h:panelGrid” tag is used to generate HTML table tags to place JSF components in rows and columns layout, from left to right, top to bottom.
For example, you used to group JSF components with HTML table tags like this :
HTML
<table>
<tbody>
<tr>
<td>
Enter a number :
</td>
<td>
<h:inputText id="number" value="#{dummy.number}"
size="20" required="true"
label="Number" >
<f:convertNumber />
</h:inputText>
</td>
<td>
<h:message for="number" style="color:red" />
</td>
</tr>
</tbody>
</table>
With “h:panelGrid” tag, you can get the same table layout above, without typing any of the HTML table tags :
h:panelGrid
<h:panelGrid columns="3">
Enter a number :
<h:inputText id="number" value="#{dummy.number}"
size="20" required="true"
label="Number" >
<f:convertNumber />
</h:inputText>
<h:message for="number" style="color:red" />
</h:panelGrid>
Note
The “column” attribute is optional, which define the number of columns are required to lay out the JSF component, defaults to 1.
h:panelGrid example
A JSF 2.0 example to show you how to use the “h:panelGrid” tag to lay out the components properly.
1. Managed Bean
A dummy bean for demo.
package com.mkyong;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name="dummy")
@SessionScoped
public class DummyBean implements Serializable{
int number;
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
2. JSF Page
A JSF XHTML page to use “h:panelGrid” tag to places JSF components in 3 columns layout.
<?xml version="1.0" encoding="UTF-8"?>
<!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:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<h1>JSF 2 panelGrid example</h1>
<h:form>
<h:panelGrid columns="3">
Enter a number :
<h:inputText id="number" value="#{dummy.number}"
size="20" required="true"
label="Number" >
<f:convertNumber />
</h:inputText>
<h:message for="number" style="color:red" />
</h:panelGrid>
<h:commandButton value="Submit" action="result" />
</h:form>
</h:body>
</html>
Output following HTML result :
<?xml version="1.0" encoding="UTF-8"?>
<!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">
<body>
<h1>JSF 2 panelGrid example</h1>
<form id="j_idt6" name="j_idt6" method="post"
action="/JavaServerFaces/faces/default.xhtml"
enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt6" value="j_idt6" />
<table>
<tbody>
<tr>
<td>
Enter a number :
</td>
<td>
<input id="j_idt6:number" type="text"
name="j_idt6:number" value="0" size="20" />
</td>
<td></td>
</tr>
</tbody>
</table>
<input type="submit" name="j_idt6:j_idt10" value="Submit" />
<input type="hidden" .... />
</form>
</body>
</html>
- Demo
Screen shot of this example.


JSF 2 panelGrid example的更多相关文章
- 关于JSF中immediate属性的总结(二)
The immediate attribute in JSF is commonly misunderstood. If you don't believe me, check out Stack O ...
- JSF标签的使用2
n 事件监听器是用于解决只影响用户界面的事件 Ø 特别地,在beans的form数据被加载和触发验证前被调用 • 用immediate=“true”指明这个行为不触发验证 Ø 在监听器调用 ...
- JSF 与 HTML 标签的联系
*页面的开头 <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ t ...
- Winter is coming Just have a little faith. JSF框架简介与实例
JSF 体系结构: JSF 的主要优势之一就是它既是Java Web应用程序的用户界面标准又是严格遵循模型-视图-控制器 (MVC) 设计模式的框架.用户界面代码(视图)与应用程序数据和逻辑(模型)的 ...
- JSF2.0 タグ一覧 (h:panelGrid) 編
JSF の HTML (UIComponent) 系タグにはテーブルを作成するタグが2種類用意されています.これらのタグと固有機能系タグを組み合わせることでテーブルを使用した画面を作成可能です. 6. ...
- JSFのAjaxタグのoneventでbegin/complete/successを使う
PrimeFacesに慣れてしまって.通常のHTMLタグでの記述方法がわからなかったりする点があった…ので.メモ. Ajaxでリクエスト送信のタイミングやレスポンスが戻るタイミングに何らか(JavaS ...
- JSF标签大全详解
1. JSF入门 藉由以下的几个主题,可以大致了解JSF的轮廓与特性,我们来看看网页设计人员与应用程序设计人员各负责什么. 1.1简介JSF Web应用程序的开发与传统的单机程序开发在本质上存在着太多 ...
- 【转】JSF中的三大核心组件 UI标签的详细介绍和使用举例
JSF提供了大量的UI标签来简化创建视图.这些UI标签类似于ASP.NET中的服务器组件.使用这些标签,可以通过其value,binding,action,actionListener等属性直接绑定到 ...
- JavaServer Faces (JSF) with Spring
JavaServer Faces (JSF) with Spring Last modified: April 30, 2018 by baeldung Spring+ Spring MVC JSF ...
随机推荐
- R语言缺失值信息处理
mean(!is.na(mat))可以计算数据完整度(没有缺失值的) mean(!is.na(mat))>0.9,90%完整可以使用 # 缺失值的位置研究as.vector(attributes ...
- [ionic开源项目教程] - 第4讲 通Service层获取数据列表
第4讲:通Service层获取数据列表 上一讲中页面的基本架构已完成,这一讲介绍如何通过service层从服务器请求数据,在通过controller层为载体,显示到视图层. 1.在services.j ...
- checkbox美化;给div加上checked属性
DIV的背景图修改 $("#isOpenmibao").css("backgroundImage", " url('../images/checkbo ...
- Maven的功用所引发的哲学思想
我们知道Maven有三个仓库 本地仓库 ~/.m2/repository/ 每一个用户也可以拥有一个本地仓库 远程仓库 中央仓库:Maven默认的远程仓库 http://repo1.maven.org ...
- [转]glew, glee与 gl glu glut glx glext的区别和关系
原文地址:http://blog.csdn.net/delacroix_xu/article/details/5881942 因为也是初接触,所以就当了解,等深入学习后再回顾这篇文章观点. GLEW是 ...
- pg 匹配中文字符
用到了正则表达式: 字段 ~'[\u4E00-\u9FA5]+$'; 注意:此表达式可能还不能取到最全的值.
- Notepad 列编辑、正则查找、替换
目标: 将源数据转成初始化sql语句.源数据: 104110040018,1,中国银行,中国银行天津琼州道支行,NULL,1100,天津市,12,天津市 104110040059,1,中国银行,中国银 ...
- Android Retrofit实现原理分析
retrofit有几个关键的地方. 1.用户自定义的接口和接口方法.(由动态代理创建对象.) 2.converter转换器.(把response转换为一个具体的对象) 3.注解的使用. 让我们跟随Ap ...
- Javascript模块化编程(三):require.js的用法 (转)
转自:http://my.oschina.net/u/1390066/blog/213769 一.为什么要用require.js? 最早的时候,所有Javascript代码都写在一个文件里面,只要加载 ...
- JBPM4之decision节点:3、程序猿|菜鸟|攻城狮|牛人
JBPM入门系列文章: JBPM4入门——1.jbpm简要介绍 JBPM4入门——2.在eclipse中安装绘制jbpm流程图的插件 JBPM4入门——3.JBPM4开发环境的搭建 JBPM4入门—— ...