1

私はJSFページを書いていますが、コマンドボタンはページの読み込み時にそのアクションを何度も呼び出しますが、誰もそれをクリックしませんでした...これは私の全体の進行を台無しにします...

HTML:

<h:panelGrid columns="2" cellpadding="10">  
<h:form>
    <table>
        <tr>
            <td>姓名:&lt;/td>
            <td><p:inplace editor="true"><p:inputText value="#{user.name}"/></p:inplace></td>
        </tr>
        <tr>
            <td>联系方式:&lt;/td>
            <td><p:inplace editor="true"><p:inputText value="#{user.phone}"/></p:inplace></td>
        </tr>
        <tr>
            <td>性别:&lt;/td>
            <td><h:outputText value="#{user.gender}"/></td>
        </tr>
        <tr>
            <td>身份证号:&lt;/td>
            <td><p:inplace editor="true"><p:inputText value="#{user.pid}"/></p:inplace></td>
        </tr>
        <tr>
            <td style="position:absolute; right:30px;"><p:commandButton value="删除" action="#{info.removeUser()}"/></td>
        </tr>
    </table>

</h:form>

java:

public void removeUser(){
    System.out.println("Current tab:"+index +" Removed............");
    users.remove(Integer.parseInt(index));
}

ここで、「インデックス」は、文字列であるaccordionPanelの現在のタブです。

ここで質問する最初の時間、多分私はいくつかの情報を省略しました...

4

1 に答える 1

1

pこれは、ビューで XML 名前ページを宣言するのを忘れた場合に発生する可能性があります。

xmlns:p="http://primefaces.org/ui"

pXML 名前空間の宣言を忘れると、すべてのp:xxxタグがプレーン テキストとして扱われます。属性内のすべての EL 式は、プレーン テキストに埋め込まれているかのように即座に実行されます。これには#{info.removeUser()}表現も含まれます。その「何度も」は、EL 式がビューに表示されるのと同じ量である可能性が最も高いです。

于 2012-09-10T18:33:47.060 に答える