谁能给我提供一个如何使用 rich:orderingList 控件的例子?我已经达到了可以按需要显示数据的地步,但现在我实际上希望将修改后的订单传播到服务器。我找不到关于该主题的任何内容。
<rich:orderingList value="#{countryHandler.data}" var="country">
<rich:column>
<f:facet name="header">
<h:outputText value="id"/>
</f:facet>
<h:outputText value="#{country.id}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="code"/>
</f:facet>
<h:outputText value="#{country.code}"/>
</rich:column>
我的支持 bean 定义了一个属性数据,它只返回一个 List
再说一遍:如何将更改后的对象顺序填充回服务器?
最佳答案
当您提交表单时,Seam 会为您重新排序列表 (#{countryHandler.data}),因此此时您应该可以访问。我举了一个简单的例子来测试这个。所有文件如下:
国家处理器.java
@Name("countryHandler")
@Scope(ScopeType.CONVERSATION)
public class CountryHandler {
@In(create=true)
private CountryService countryService;
private List<Country> data;
public void loadCountries() {
this.data = this.countryService.getCountryList();
}
public List<Country> getData() {
return data;
}
public void setData(List<String> data) {
this.data = data;
}
public void submit() {
//check the list order here. You should find it's ordered...
}
}
国家.xhtml
...snip...
<rich:orderingList value="#{countryHandler.data}" var="country">
<rich:column>
<f:facet name="header">
<h:outputText value="id"/>
</f:facet>
<h:outputText value="#{country.id}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="code"/>
</f:facet>
<h:outputText value="#{country.code}"/>
</rich:column>
</rich:orderingList>
<h:commandButton action="#{countryHandler.submit()}" value="Submit" />
...snip...
国家.page.xml
<page>
...snip...
<begin-conversation join="true"/>
<action execute="#{countryHandler.loadCountries()}"/>
...snip...
</page>
另见:
关于java - 丰富的 :orderingList usage example,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1141942/