不会更改JSF上的输出文本值



我制作了一个带有PrimeFaces的Web项目。我将txt文件上传到数据表上,然后进行一些特定的进程,然后想在分配列上进行一些更改,但是当我输入某种内容时,outputText不会更改。但是输入文本会更改。我的意思是,如果单击该行,显示了新值,但没有显示旧值。这是我的代码

@ManagedBean@ViewScoped public class MessageTableController implements Serializable {
private static final long serialVersionUID = 20111020L;
private List<preList> kullaniciList;
private UploadedFile file;
private File f;
private BufferedReader br;
private String line;
private String[] str;

public List<preList> getKullaniciList() {
    return kullaniciList;
}
public void setKullaniciList(List<preList> kullaniciList) {
    this.kullaniciList = kullaniciList;
}
public UploadedFile getFile() {
    return file;
}
public void setFile(UploadedFile file) {
    this.file = file;
}
public void upload() throws IOException {
    if (file != null) {
        FacesMessage message = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
        FacesContext.getCurrentInstance().addMessage(null, message);
        readUploadedFile();
    }
}
public void readUploadedFile() throws IOException {
    f = new File(file.getFileName());
    br = new BufferedReader(new FileReader(f));
    kullaniciList = new ArrayList<preList>();
    while ((line = br.readLine()) != null) {
        if (line.contains("PI")) {
            str = line.split("=");
            kullaniciList.add(new preList(str[0], str[1]));
        }
    }
    br.close();
}

public class preList {
    private String value;
    private String assign;
    public preList(String value, String assign) {
        this.value = value;
        this.assign = assign;
        System.out.println(value);
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        System.out.println(value);
        this.value = value;
    }
    public String getAssign() {
        return assign;
    }
    public void setAssign(String assign) {
        System.out.println(value);
        this.assign = assign;
    }
}}
  <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
    <h:form enctype="multipart/form-data">
        <p:growl id="messages" showDetail="false" />
        <p:fileUpload value="#{messageTableController.file}" mode="simple"
            skinSimple="true" />
        <p:commandButton value="Submit" ajax="false"
            actionListener="#{messageTableController.upload}" disabled="false" />
    </h:form>
    <p:dataTable id="cellEditingTable" var="message"
        value="#{messageTableController.kullaniciList}" paginator="true"
        paginatorPosition="bottom" editable="true" editMode="cell">

        <f:facet name="header">  
            PRE_INSTALL
        </f:facet>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Value" />
            </f:facet>
            <p:cellEditor>
                <f:facet name="output">
                    <h:outputText value="#{message.value}"/>
                </f:facet>
                <f:facet name="input">
                    <p:inputText value="#{message.value}"
                        style="width:96%" update="cellEditingTable"/>
                </f:facet>
            </p:cellEditor>
        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Assign" />
            </f:facet>
            <p:cellEditor>
                <f:facet name="output">
                    <h:outputText value="#{message.assign}" />
                </f:facet>
                <f:facet name="input">
                    <p:inputText value="#{message.assign}" style="width:96%" />
                </f:facet>
            </p:cellEditor>
        </p:column>
    </p:dataTable>

</h:body>
</html>

PrimeFaces Showcase使用

<p:ajax event="cellEdit" listener="#{dtEditView.onCellEdit}" update=":form:msgs" />

因此,它更新表单而不是数据表,并且没有针对输入字段的更新属性。

最新更新