我正在关注此示例:http://mkblog.exadel.com/2008/11/richfaces-built-in-sorting/
它说箭头应该出现在标题旁边,用户可以点击它进行排序。
但我无法看到箭头。你帮忙谢谢。
我使用的代码:
newwonder.xhtml
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<title>Requirement Workflow</title>
</h:head>
<h:body>
<rich:dataTable value="#{newWondersBean.sevenNewWonders}" var="wonder">
<rich:column sortBy="#{wonder.name}">
<f:facet name="header">Name</f:facet>
<h:outputText value="#{wonder.name}" />
</rich:column>
<rich:column sortBy="#{wonder.location}">
<f:facet name="header">Location</f:facet>
<h:outputText value="#{wonder.location}" />
</rich:column>
<rich:column>
<f:facet name="header">Image</f:facet>
<h:graphicImage url="#{wonder.imageUrl}" />
</rich:column>
</rich:dataTable>
</h:body>
</html>
NewWondersBean.java
package wonder;
import java.util.ArrayList;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class NewWondersBean {
private ArrayList <Wonder> sevenNewWonders = new ArrayList <Wonder>();
@PostConstruct
public void init () {
sevenNewWonders = new ArrayList <Wonder>();
sevenNewWonders.add(new Wonder("Chichen Itza", "Mexico", "http://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Chichen-Itza-Castillo-Seen-From-East.JPG/90px-Chichen-Itza-Castillo-Seen-From-East.JPG"));
sevenNewWonders.add(new Wonder("Christ the Redeemer", "Brazil", "http://upload.wikimedia.org/wikipedia/commons/thumb/5/50/CorcovadofotoRJ.jpg/90px-CorcovadofotoRJ.jpg"));
sevenNewWonders.add(new Wonder("Colosseum", "Italy", "http://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Colosseum_in_Rome%2C_Italy_-_April_2007.jpg/90px-Colosseum_in_Rome%2C_Italy_-_April_2007.jpg"));
sevenNewWonders.add(new Wonder("Great Wall of China", "China", "http://upload.wikimedia.org/wikipedia/commons/thumb/1/16/GreatWallNearBeijingWinter.jpg/90px-GreatWallNearBeijingWinter.jpg"));
sevenNewWonders.add(new Wonder("Machu Picchu", "Peru", "http://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Before_Machu_Picchu.jpg/90px-Before_Machu_Picchu.jpg"));
sevenNewWonders.add(new Wonder("Petra", "Jordan", "http://upload.wikimedia.org/wikipedia/commons/thumb/0/06/PetraMonastery.JPG/90px-PetraMonastery.JPG"));
sevenNewWonders.add(new Wonder("Taj Mahal", "India", "http://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Taj_Mahal_in_March_2004.jpg/90px-Taj_Mahal_in_March_2004.jpg"));
}
public ArrayList <Wonder> getSevenNewWonders() {
return sevenNewWonders;
}
}
Wonder.java
package wonder;
public class Wonder {
public Wonder(String string, String string2, String string3) {
// TODO Auto-generated constructor stub
this.name = string;
this.location = string2;
this.imageUrl = string3;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setLocation(String location) {
this.location = location;
}
public String getLocation() {
return location;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getImageUrl() {
return imageUrl;
}
private String name;
private String location;
private String imageUrl;
}
答案 0 :(得分:6)
据我了解,Richfaces 4已经改变了排序。
您需要拥有Map <String, SortOrder>
,并且需要在rich:column中添加一个属性,其中sortOrders是上面的Map,而vendor是给定列的键。
sortOrder="#{bean.sortsOrders['vendor']}">
之后,排序几乎是自动魔术,但是图标也不在Richfaces 4中,因此您将手动根据每列的SortOrder枚举值添加这些图标。
我认为从3.x开始是一种痛苦和倒退,但这就是让排序工作所需要的。
您可以随时查看RichFaces Showcase网站以获取更多信息
编辑:(2013年1月)
随着即将推出的RichFaces 4.3自动排序正在重新添加,并将包括箭头和不包括的箭头。上面的链接应该有一个很好的选择。
编辑:( 2013年9月) RF现在是4.3.4版本,自动排序仍然没有回来。它只适用于rich:extendedDataTable,但不适用于rich:dataTable