<%@ 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);
}