PrimeFaces布局技巧之二

10 篇文章 0 订阅
作者:chszs,转载需注明。博客主页:http://blog.csdn.net/chszs

本文紧接《 PrimeFaces布局技巧 》。

要注意:当使用整页布局和表单一起工作时,要避免表单内包含布局单元,它可能会导致错误。比如下面的代码可能就是无效的:
[html]  view plain copy print ?
  1. <p:layout fullPage="true">  
  2.   <h:form>  
  3.     <p:layoutUnit position="west" size="100">  
  4.       <h:outputText value="Left Pane" />  
  5.     </p:layoutUnit>  
  6.     <p:layoutUnit position="center">  
  7.       <h:outputText value="Right Pane" />  
  8.     </p:layoutUnit>  
  9.   </h:form>  
  10. </p:layout>  

布局单元必定有自己的表单,因此要避免更新布局单元,应该是更新内容而不更新布局。

除了布局的“中中center”区域,其它区域都必须有自己的尺寸大小,使用size选项。

布局的另一种使用情况是基于元素的布局。它实际上相当于把整页布局fullPage属性设置为false。

布局使用到的皮肤样式类由于皮肤样式类是全局的,在主题那一章可以看到更详细的信息。


布局使用到的皮肤样式类



布局单元LayoutUnit
布局单元表示边框布局模型的一个区域。
布局单元的属性包括:


注:红色字体部分是我修订过的结果,PrimeFaces官网的文档有错误。

布局示例:


代码样例:
[html]  view plain copy print ?
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml"  
  3.     xmlns:h="http://java.sun.com/jsf/html"  
  4.     xmlns:f="http://java.sun.com/jsf/core"  
  5.     xmlns:ui="http://java.sun.com/jsf/facelets"  
  6.     xmlns:p="http://primefaces.org/ui">  
  7.   
  8. <f:view contentType="text/html">  
  9.     <h:head>  
  10.         <f:facet name="first">  
  11.             <meta http-equiv="X-UA-Compatible" content="EmulateIE8" />  
  12.             <meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />  
  13.             <title>PrimeFaces Layout</title>  
  14.         </f:facet>  
  15.         <style type="text/css">  
  16.         </style>  
  17.     </h:head>  
  18.   
  19.     <h:body>  
  20.         <p:layout fullPage="true">  
  21.             <p:layoutUnit position="north" size="100" header="Top" resizable="true" closable="true" collapsible="true">  
  22.                 <h:outputText value="顶部区域" />  
  23.             </p:layoutUnit>  
  24.   
  25.             <p:layoutUnit position="south" size="100" header="Bottom" resizable="true" closable="true" collapsible="true">  
  26.                 <h:outputText value="底部区域" />  
  27.             </p:layoutUnit>  
  28.   
  29.             <p:layoutUnit position="west" size="300" header="左部" collapsible="true" footer="左底" gutter="1" effect="drop">  
  30.                 <p:accordionPanel>  
  31.                     <p:tab title="菜单1">  
  32.                         <h:outputText value="菜单1测试" />  
  33.                     </p:tab>  
  34.   
  35.                     <p:tab title="菜单2">  
  36.                         <h:outputText value="菜单2测试" />  
  37.                     </p:tab>  
  38.   
  39.                     <p:tab title="菜单3">  
  40.                         <h:outputText value="菜单3测试" />  
  41.                     </p:tab>  
  42.                 </p:accordionPanel>  
  43.             </p:layoutUnit>  
  44.   
  45.             <p:layoutUnit position="center" closable="true" collapsible="true" header="Contents">  
  46.                 <h:form>  
  47.                     布局组件Layout是一个高度可定制的边框布局模型,它可以很轻松地创建复杂的网页布局,即使不懂Web设计。布局组件Layout是一个高度可定制的边框布局模型,它可以很轻松地创建复杂的网页布局,即使不懂Web设计。布局组件Layout是一个高度可定制的边框布局模型,它可以很轻松地创建复杂的网页布局,即使不懂Web设计。布局组件Layout是一个高度可定制的边框布局模型,它可以很轻松地创建复杂的网页布局,即使不懂Web设计。  
  48.                 </h:form>  
  49.             </p:layoutUnit>  
  50.         </p:layout>  
  51.     </h:body>  
  52.   
  53. </f:view>  
  54. </html>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值