2

私は豊富なdataTableに問題があります実際にはデータベースからそのdataTableにデータを入力し、inplaceInputを入れることで列を編集可能にしました問題はバッキングビーンに送信するときです値は変更されませんバッキングビーンには古いデータが取り込まれています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 が機能しません :( 助けてください

4

0 に答える 0