0

List cites と呼ばれるプロパティを持つバッキング Bean があり、Cite には "value" と呼ばれる文字列プロパティがあります。引用のリスト。しかし、ユーザーが既存の引用の上にさらに引用を追加したり、既存の引用コンテンツを編集したりできるようにしたいと考えています。どうやってやるの ?以下のコードは xhtml の jsf ですが、私にはうまくいきません..

<div style="margin-top: 10px; padding: 3px 3px;">
                    <fieldset>                          
                        <legend>Cites Affected</legend>
                        <h:dataTable value="#{dataEntry.cites}" var="citeAffected">
                            <h:column>
                            <f:facet name="header" >
                                <h:outputText value="Cite"/>
                            </f:facet>    
                            <h:inputText value="#{citeAffected.value}"/>
                            </h:column>
                        </h:dataTable>
                    <h:commandButton value="Add cite" process="@this" action="#{dataEntry.addCite}"/>                       
                    </fieldset>
                </div>

バッキングビーンで..これは私が持っているものです

DataEntry
{
private List<CiteAffected> cites = new ArrayList<CiteAffected>();

public void addCite()
{
cites.add(new CiteAffected());
} 

public void editMetadata()
{
//update the db object 
}
private void init()
{

// get the value from database as a comma separated string
for(String citeAffected : Arrays.asList(sourceManualLoadProperties.getCitesAffected().split(",")))
            {
                CiteAffected cite = new CiteAffected();
                cite.setValue(citeAffected);
                this.cites.add(cite);
}           }
}

私が得ているエラーは..コマンドボタン「引用を追加」をクリックするとすぐに、別のテキストボックスを追加するだけで既存の値も表示したいときに既存の値がすべて消えます..

public class CiteAffected
{
    private String value;

    /**
     *
     * @return the cite affected
     */
    public String getValue()
    {
        return value;
    }

    /**
     *
     * @param value the cite affected
     */
    public void setValue(final String value)
    {
        this.value = value;
    }
}
4

1 に答える 1