0

データテーブルがあり、列の 1 つに特定のアイテムのステータスが含まれています。ステータスは、列に commandLink として表示されます。データベースから取得したアイテムのステータスが Status1,Status 2 のようなカンマ区切り値の場合、同じアイテムの列に 2 つのコマンドリンクを表示する必要があります。1 つは Status1 で、もう 1 つは Status 2 です。

<h:commandLink id="status1Link" value="#{pc_test.status1}"
                            onclick="showAssignKeyRvPopup(#{plist.t3Id},'#{plist.t3FileName}','#{plist.status}');return false;"
                            rendered="#{plist.status == 'Status1,Status2'}"
                            update="assignKeyRvDialog">
                        </h:commandLink> 

上記は、commandLink を表示するために使用しているコードです。クリックするとポップアップが表示され、そこからOKをクリックすると、ステータスを再度更新するアクションを実行する必要があります。同じ列に 2 つの commandLinks があります。私の質問は、1 つの commandLink をクリックしてアクションを実行したときに、その commandLink のテキストのみを変更し、他のものは変更したくないということです。そのため、クリックした commandLink の ID を渡す必要があります。どうすればこれを行うことができるか教えてください。

あなたが提案したのと同じように試しました-

<p:remoteCommand name="doSubmit" actionListener="#{pc_testmaps.doAssignUser}" />

<p:commandButton id="assignUser" value="Submit" onclick="doSubmit();"> </p:commandButton>

function doSubmit() {
            document.getElementById('nonMCLink') = commandLinkId;
            doAssignUser([{name:'commandLinkId', value:commandLinkId}]);
        }

And in the bean, 

public void doAssignUser() throws DelegateException {

        FacesContext context = FacesContext.getCurrentInstance();
        Map<String, String> map = context.getExternalContext().getRequestParameterMap();
        String linkStatus = (String) map.get("commandLinkId");
        System.out.println(linkStatus);
}

linkStatus の値を出力すると、null として取得されます。助けてください。

4

1 に答える 1

1

Primefaces を使用すると、 p:remoteCommandで簡単に実行できます 。

最初に、commandLinkjavascript を使用して ID を取得すると、アクションを使用してそれを Bean に取得できます。

ここに簡単な例があります。これをチェックしてください。

remoteCommand の使用

アップデート

    <p:remoteCommand name="doSubmit"
        actionListener="#{yourBean.doSubmit}" />

<script type="text/javascript">
function onOKclick() {
$(document).ready(function() {
    var commandLinkID = "yourcommandlinkId" //or get id using javascript with name          
doSubmit([{name:'commandLinkID', value:commandLinkID}]);
    });         
}
</script>

ポップアップの OK ボタン

  <h:commandButton onclick="onOKclick();" /> 
//calling onOKclick js function is important.you can call onOkclikc js function where you want 

Bean の doSubmitMethod;

public void doSubmit(){
  FacesContext context = FacesContext.getCurrentInstance();
            Map<String, String> map = context.getExternalContext().getRequestParameterMap();
           String value = (String) map.get("commandLinkID");
System.out.print(value);


}

多分それはあなたです。

于 2012-10-18T10:03:23.357 に答える