JSF Logic: Dymanically display images and change text style
来源:互联网 发布:阿里布达年代txt百度云 编辑:程序博客网 时间:2024/04/27 20:21
For this sample, the key issue is to use binding attribute of dataTable, and rendered, style attributes of graphicImage and outputText respectively.
OK, let's take a look at the JSP source code:
<hx:dataTableEx id="tableEx1"
<hx:columnEx id="columnEx1">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Order_details"
</f:facet>
<h:outputText id="textOrder_details1"
</h:outputText>
<hx:graphicImageEx id="imageEx1" styleClass="graphicImageEx"
</hx:graphicImageEx>
</hx:columnEx>
We use the binding attribute to bind the current dataTable instance to a UIData which is listData in this case, and use style and rendered attributes to control the appearance. They are all integrated into the OrderStyle javabean:
public class OrderStyle {
UIData listData = new UIData();
boolean displayYellow;
String boldStyle;
int order_id =((Order)(listData.getRowData())).getOrder_id();
if(order_id==0||order_id==2||order_id==3)
boldStyle ="font-weight: bold";
//boldStyle="boldSytle";
else
boldStyle = "font-weight: 400";
//boldStyle="normalStyle";
return boldStyle;
}
public void setBoldStyle(String boldStyle) {
this.boldStyle = boldStyle;
}
public boolean isDisplayYellow() {
int order_id =((Order)(listData.getRowData())).getOrder_id();
if(order_id==0||order_id==1||order_id==4)
displayYellow= true;
else
displayYellow= false;
return displayYellow;
}
public void setDisplayYellow(boolean displayYellow) {
this.displayYellow = displayYellow;
}
public UIData getListData() {
return listData;
}
public void setListData(UIData listData) {
this.listData = listData;
}
...
}
That's all! (Notice: In this way, the style is applied only to the column, not to the row.)
Now you may ask, could we change the row background* based on logic? The answer is yes. Please keep tracking which is coming soon...
* After test, the way we are using to change the row background according to logic is only suitable to the data table without paging. Here is the code we use, we bind the rowClasses attribute of dataTable to the variable rowColorStyle:
to get the row style, getRowStyle function in OrdersRowStyle is invoked:
- JSF Logic: Dymanically display images and change text style
- Enumerate and Change Display Modes
- Showing Images and Text in Toolbar
- style.display
- style.display
- text style
- How to use OpenCV to capture and display images from a camera
- Use eof() to read and display a text file.
- Use eof() to read and display a text file.
- style.display 和 style.visibility
- Html: display text in monospaced style (including special char space/hyphen etc.) - tag <tt>
- Style.display 的用法
- style.display问题
- style.display 属性
- DIV的style.display
- js style的display
- style="display:none"
- Style display 属性
- Roller3.1的安装及“Roller遇到一个意外错误”的解决[00原创]
- 抓狂..
- 常见包依赖问题及解决
- Informix HDR Setting in WebSphere Application Server
- P2P之UDP穿透NAT的原理与实现(附源代码)
- JSF Logic: Dymanically display images and change text style
- P2P之NAT类型检测方法
- UDP套接口相关
- SIP协议概要介绍
- 二战中最无耻的十个国家:苏联第一 日本第二
- 度量衡单位换算表
- Visual Studio.NET 术语大全
- Java异常处理的陋习展播
- maven2创建web工程