富数据表更新问题

时间:2012-12-26 10:32:59

标签: jsf datatable richfaces

我遇到了丰富的dataTable问题 实际上,我从数据库中填充了dataTable,并通过在其中放入一个inplaceInput使列可编辑,问题是当我提交给支持bean时值不会改变支持bean填充最初填充dataTable的旧值: 这是我的JSF代码表:

<center>
        <fieldset><rich:dataTable id="tablefiles"
            value="#{fileBean.files}" var="file" rows="8"
            iterationStatusVar="it">

            <rich:column id="Child_Code">
                <f:facet name="header">
                    <h:outputText value="N°tiers filiale" />
                </f:facet>
                <h:outputText value="#{file.child_Code}" />
            </rich:column>

            <rich:column id="Mother_Code">
                <f:facet name="header">
                    <h:outputText value="Nom du groupe" />
                </f:facet>
                <!--  <h:inputText value="#{file.mother_Code}" />-->
                <rich:inplaceInput defaultLabel="Click here to edit"
                    showControls="false" controlsHorizontalPosition="left"
                    controlsVerticalPosition="bottom" id="inplaceInput"
                    value="#{file.mother_Code}"
                    >
                </rich:inplaceInput>
            </rich:column>



            <rich:column>
                <f:facet name="header" roles="#riskuser">
                    <h:outputText value="Détail" />
                </f:facet>
                <h:commandLink action="#{fileBean.accesDetail}">
                    <h:graphicImage value="/images/edit.png" alt="edit"
                        style="border:0;" title="Détail " />
                    <f:setPropertyActionListener target="#{fileBean.selectedFile}"
                        value="#{file}" />
                </h:commandLink>
            </rich:column>



            <f:facet name="footer">
                <rich:dataScroller page="#{fileBean.page}" />
            </f:facet>
        </rich:dataTable> <br />

        <h:panelGrid columns="3" id="buttonRow">

            <a4j:commandButton value="Save" render="tablefiles" execute="@form"
                action="#{fileBean.update}">

            </a4j:commandButton>

        </h:panelGrid></fieldset>
        </center>`<center>
        <fieldset><rich:dataTable id="tablefiles"
            value="#{fileBean.files}" var="file" rows="8"
            iterationStatusVar="it">

            <rich:column id="Child_Code">
                <f:facet name="header">
                    <h:outputText value="N°tiers filiale" />
                </f:facet>
                <h:outputText value="#{file.child_Code}" />
            </rich:column>

            <rich:column id="Mother_Code">
                <f:facet name="header">
                    <h:outputText value="Nom du groupe" />
                </f:facet>
                <!--  <h:inputText value="#{file.mother_Code}" />-->
                <rich:inplaceInput defaultLabel="Click here to edit"
                    showControls="false" controlsHorizontalPosition="left"
                    controlsVerticalPosition="bottom" id="inplaceInput"
                    value="#{file.mother_Code}"
                    >
                </rich:inplaceInput>
            </rich:column>



            <rich:column>
                <f:facet name="header" roles="#riskuser">
                    <h:outputText value="Détail" />
                </f:facet>
                <h:commandLink action="#{fileBean.accesDetail}">
                    <h:graphicImage value="/images/edit.png" alt="edit"
                        style="border:0;" title="Détail " />
                    <f:setPropertyActionListener target="#{fileBean.selectedFile}"
                        value="#{file}" />
                </h:commandLink>
            </rich:column>



            <f:facet name="footer">
                <rich:dataScroller page="#{fileBean.page}" />
            </f:facet>
        </rich:dataTable> <br />

        <h:panelGrid columns="3" id="buttonRow">

            <a4j:commandButton value="Save" render="tablefiles" execute="@form"
                action="#{fileBean.update}">

            </a4j:commandButton>

        </h:panelGrid></fieldset>
        </center>

这是我的bean代码:

 package ui.bean;

import java.io.Serializable;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import business.ISRGGestionGarantieCasa;

import common.pojo.SRGarantieCasa;

@ManagedBean
@SessionScoped
public class GarantiCasaBean implements Serializable {

private static final long serialVersionUID = -1509108399715814312L;
private ISRGGestionGarantieCasa fileService;
private int idMsg;
private int page = 1;
private String id_r;
private List<SRGarantieCasa> files = new ArrayList<SRGarantieCasa>();
private SRGarantieCasa selectedFile, file;
private List<String> suggestions = null;

public List<String> getSuggestions() {
    return suggestions;
}

public void setSuggestions(List<String> suggestions) {

    this.suggestions = suggestions;
}

public SRGarantieCasa getSelectedFile() {
    return selectedFile;
}

public void setSelectedFile(SRGarantieCasa selectedfile) {
    this.selectedFile = selectedfile;
}

public ISRGGestionGarantieCasa getFileService() {
    return fileService;
}

public void setFileService(ISRGGestionGarantieCasa fileService) {
    this.fileService = fileService;
}

public int getIdMsg() {
    return idMsg;
}

public void setIdMsg(int idMsg) {
    this.idMsg = idMsg;
}

public int getPage() {

    return page;
}

public void setPage(int page) {

    this.page = page;
}



public String getId_r() {
    return id_r;
}

public void setId_r(String id_r) {
    this.id_r = id_r;
}

public List<SRGarantieCasa> getFiles() {
    return files;
}

public void setFiles(List<SRGarantieCasa> files) {
    this.files = files;
}

public String viderChamps() {
    // vider les champ
    id_r = "";
    return null;
}

public String search() {
    if (id_r == "") {
        files = fileService.getListeFiles();
    } else {
        files.clear();
        files = fileService.getFile(id_r);
    }
    return null;
}

public String accesDetail() {
    return "GCUpdate?faces-redirect=true";
}

public String saveFile() {
    fileService.updateFile(selectedFile);
    return "GarantieCasa?faces-redirect=true";

}

public String ajoutFile() {

    fileService.addfile(file);
    return "GarantieCasa?faces-redirect=true";

}

public String addFile() {
    return "GarantieCasaAdd?faces-redirect=true";
}

public SRGarantieCasa getFile() {
    return file;
}

public void setFile(SRGarantieCasa file) {
    this.file = file;
}

public GarantiCasaBean() {
    /*
     * suggestions = new ArrayList<String>(); suggestions.add("Banana");
     * suggestions.add("Cranberry"); suggestions.add("Blueberry");
     * suggestions.add("Orange"); suggestions.add("Apple");
     * suggestions.add("Strawberry");
     */
}
 public void update()
    {
     for (SRGarantieCasa selectedFile : fileService.getListeFiles()){
         System.out.println("GarantieCasaBean : Mother Code :"+selectedFile.getMother_Code());
        fileService.updateFile(selectedFile);

     }
        //return "GarantieCasa?faces-redirect=true";
    }

}

这是春天的conf:

<!-- Service UI -->
<bean id="fileBean" class="ui.bean.GarantiCasaBean" scope="request">
    <property name="fileService" ref="SO_GestionFile" />
    <property name="file" ref="fileCGC" />
</bean>

<bean id="fileCGC" class="common.pojo.SRGarantieCasa" scope="session" />

我在该主题中发现了同样的问题: Richfaces editable dataTable not setting updated values in Bean

但我是@this,@ All不适合我:(请帮帮我

0 个答案:

没有答案