<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
一.资源文件的反编译:native2ascii -reverse -encoding gb2313 b.properties a.properties
二.
<f:verbatim>组件用于将HTML元素添加到页面中,并使 HTML
元素具有这些组件的行为。直接把HTML元素放在<h:panelGroup>中会发生错误,因为HTML元素并不是JSF的子组件。如果使
用 Faces Verbatim 组件,请确保遵循以下准则:
三.HTML编辑器组件:<t:inputHtml id="inputHtml" value="#{dvoFace.map['inputHtml']}" displayValueOnly="#{dvoFace.attribute}"/>
四.Tomahawk 组件中的 forceId 属性能使生成出来的组件ID不像JSF生成出来的form:cid 的形式,forceId="true"使生成出来的ID就是实际编写的ID。
五.<t:validate*/>组件中包含大量已定义的验证:
<t:validateEmail /> 电子邮件验证
<t:validateCreditCard /> 信用卡验证
<t:validateRegExpr pattern='\d{5}' /> 使用正则表达式验证
<t:validateEqual for="equal" /> 与id="equal"的组件组做相等验证
六.aliasBean和aliasBeanScope(aliasBeanScope组件里可以设置多个aliasBean组件.)组件可以为subview里有组件或页面以别名的方式为当前view传递bean
<t:aliasBean alias="#{ali}" value="#{alibean}">
<f:subview id="subviewer">
<t:outputText forceId="true" id="ot" value="#{ali.name}"></t:outputText>
</f:subview>
</t:aliasBean>
七.<t:buffer>组件的使用:
<t:buffer into="#{buffer1}">
<t:div><h:outputText value="Buffer One"/></t:div>
</t:buffer>
<t:buffer into="#{buffer2}">
<t:div><h:outputText value="Buffer Two"/></t:div>
</t:buffer>
<h:outputText value="#{buffer2}" escape="false"/>
<h:outputText value="#{buffer1}" escape="false"/>
<h:outputText value="#{buffer2}" escape="false"/>
它可以把内容先缓冲起来,再用<h:outputText>组件显现出来,这样就可以把顺序比较后的组件先render出来。
八.在table的排序:
- <t:dataTable styleClass="standardTable"
- headerClass="standardTable_SortHeader"
- footerClass="standardTable_Footer"
- rowClasses="standardTable_Row1,standardTable_Row2"
- var="car"
- value="#{list.cars}"
- sortColumn="#{list.sort}"
- sortAscending="#{list.ascending}"
- preserveDataModel="true"
- preserveSort="true">
-
- <f:facet name="header">
- <h:outputText value="(header table)" />
- </f:facet>
- <f:facet name="footer">
- <h:outputText value="(footer table)" />
- </f:facet>
-
- <h:column>
- <f:facet name="header">
- <t:commandSortHeader columnName="type" arrow="true">
- <h:outputText value="#{example_messages['sort_cartype']}" />
- </t:commandSortHeader>
- </f:facet>
- <h:outputText value="#{car.type}" />
- <f:facet name="footer">
- <h:outputText id="ftr1" value="(footer col1)" />
- </f:facet>
- </h:column>
-
- <h:column>
- <f:facet name="header">
- <t:commandSortHeader columnName="color" arrow="true">
- <h:outputText value="#{example_messages['sort_carcolor']}" />
- </t:commandSortHeader>
- </f:facet>
- <h:outputText value="#{car.color}" />
- <f:facet name="footer">
- <h:outputText id="ftr2" value="(footer col2)" />
- </f:facet>
- </h:column>
-
- </t:dataTable>
<t:dataTable styleClass="standardTable"
headerClass="standardTable_SortHeader"
footerClass="standardTable_Footer"
rowClasses="standardTable_Row1,standardTable_Row2"
var="car"
value="#{list.cars}"
sortColumn="#{list.sort}"
sortAscending="#{list.ascending}"
preserveDataModel="true"
preserveSort="true">
<f:facet name="header">
<h:outputText value="(header table)" />
</f:facet>
<f:facet name="footer">
<h:outputText value="(footer table)" />
</f:facet>
<h:column>
<f:facet name="header">
<t:commandSortHeader columnName="type" arrow="true">
<h:outputText value="#{example_messages['sort_cartype']}" />
</t:commandSortHeader>
</f:facet>
<h:outputText value="#{car.type}" />
<f:facet name="footer">
<h:outputText id="ftr1" value="(footer col1)" />
</f:facet>
</h:column>
<h:column>
<f:facet name="header">
<t:commandSortHeader columnName="color" arrow="true">
<h:outputText value="#{example_messages['sort_carcolor']}" />
</t:commandSortHeader>
</f:facet>
<h:outputText value="#{car.color}" />
<f:facet name="footer">
<h:outputText id="ftr2" value="(footer col2)" />
</f:facet>
</h:column>
</t:dataTable>
list.sort:
- protected void sort(final String column, final boolean ascending)
- {
- Comparator comparator = new Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- SimpleCar c1 = (SimpleCar)o1;
- SimpleCar c2 = (SimpleCar)o2;
- if (column == null)
- {
- return 0;
- }
- if (column.equals("type"))
- {
- return ascending ? c1.getType().compareTo(c2.getType()) : c2.getType().compareTo(c1.getType());
- }
- else if (column.equals("color"))
- {
- return ascending ? c1.getColor().compareTo(c2.getColor()) : c2.getColor().compareTo(c1.getColor());
- }
- else return 0;
- }
- };
- Collections.sort(_cars, comparator);
- }
protected void sort(final String column, final boolean ascending)
{
Comparator comparator = new Comparator()
{
public int compare(Object o1, Object o2)
{
SimpleCar c1 = (SimpleCar)o1;
SimpleCar c2 = (SimpleCar)o2;
if (column == null)
{
return 0;
}
if (column.equals("type"))
{
return ascending ? c1.getType().compareTo(c2.getType()) : c2.getType().compareTo(c1.getType());
}
else if (column.equals("color"))
{
return ascending ? c1.getColor().compareTo(c2.getColor()) : c2.getColor().compareTo(c1.getColor());
}
else return 0;
}
};
Collections.sort(_cars, comparator);
}