java - 丰富的 :orderingList usage example

标签 java jsf richfaces

谁能给我提供一个如何使用 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/

相关文章:

java - ICEFaces session 自动扩展

jsf-2 - 丰富的 :componentControl and setPropertyActionListener wont work together

java - 从数据库Java填充多维数组

java - 如何查找 URL 中的特定单词?

java - 使用 setPropertyActionListener 设置 ENUM

javascript - JSF Javascript 调用 Primefaces 组件

java - JSF 下载文件返回index.jsf

java - 丰富 :pickList selection buttons arrow in right-to-left language direction

java - 获取jmeter功能测试代码覆盖率

java - Java 中的客户端-服务器文件传输