1

事前に選択したアイコンに応じて、commandButton の ActionListener を変更したい:

        <p:dialog id="dialog" header="Add Memo" widgetVar="dialogMemo" resizable="false" >
        <h:form>
            <h:panelGrid columns="2" cellpadding="5">  
                <h:outputLabel for="commentInput" value="Comment:" />  
                <p:inputTextarea id="commentInput" value="#{dashboardBean.getCurrentComment()}" rows="6" cols="25" label="commentInput"/>
                <p:watermark for="commentInput" value="Enter your memo..."/>  
                <h:outputLabel for="selectShare" value="Share Memo: " />  
                <p:selectBooleanCheckbox id="selectShare" /> 

                <h:outputLabel for="choosePriority" value="Priority:" />  
                <p:selectOneMenu id="choosePriority" value="#{dashboardBean.currentPriority}" label="choosePriority">  
                    <f:selectItem itemLabel="Low Priority" itemValue="1" />  
                    <f:selectItem itemLabel="Medium Priority" itemValue="2" />  
                    <f:selectItem itemLabel="High Priority" itemValue="3" />  
                </p:selectOneMenu>

                <p:commandButton id="submitDialog" icon="ui-icon-check" value="Confirm" ajax='false' type="submit" action="#{dashboardBean.getLastMemo()}"/>
                <p:commandButton icon="ui-icon-close" onclick="dialogMemo.hide();" value="Cancel"/>
            </h:panelGrid>
        </h:form>
    </p:dialog>
    <p:layout fullPage="true">
        <p:layoutUnit id="leftPanel" position="west" size="250" header="My Memos" resizable="false" closable="false" collapsible="false">
            <h:form id="form"> 
                <p:commandButton id="addMemo" icon="ui-icon-plus" onclick="dialogMemo.show();" type="submit" action="#{dashboardBean.getEditControl}"/>  
                <p:dashboard id="dashboardId" model="#{dashboardBean.model}" binding="#{dashboardBean.dashboard}">
                </p:dashboard>  
            </h:form>
        </p:layoutUnit>           
</h:body>

コマンドボタン(id="addMemo")をクリックすると、actionListenerをcommandButton(id="submitDialog")に変更したい。

私はそれを試します:

public void getEditControl()
{
    UIViewRoot view = _context.getViewRoot();
    CommandButton button = (CommandButton) view.findComponent("submitDialog");

    System.out.println("I am ID ==== [ " + button.getId() +" ]");

}

しかし、「button.getId()」は機能しません。

4

2 に答える 2