ap:dialogを実装しようとしています。その中に選択リストがあります。選択した項目に基づいて、ダイアログボックスのテンプレートを更新する必要があります。これは正常に機能しています。ただし<p:commandButton>
、動的にレンダリングされたテンプレートにが含まれている場合、そのactionListenerが起動されることはありません。
例:view.xhtml
<p:dialog modal="true" id="addSocialMediaAddressDialogPanel" widgetVar="addSocialMediaAddressDialog" width="500" >
<h:form id="addSocialMediaAddressForm">
<h:messages />
<p:selectOneMenu id="currentAddingSocialMedia" value="#{requestScope.selectedMedia}" >
<f:selectItems value="#{WebResource.getListByName('SOCIAL_MEDIAS')}" />
<p:ajax update="addSocialMediaAddressContentPanel" process="@this" />
</p:selectOneMenu>
<p:outputPanel id="addSocialMediaAddressContentPanel">
<ui:include src="#{contactBean.resolveTemplate(requestScope.selectedMedia)}"/>
</p:outputPanel>
</h:form>
</p:dialog>
私はこのようなテンプレートを持っています
templates
|_ twitter.xhtml
|_ facebook.xhtml
|_ googlePlus.xhtml
twitter.xhtml
<table>
<tr>
<td>
<h:outputLabel styleClass="standardText" value="Twitter Screen Name"/>
</td>
<td>
<p:inputText id="twitterScreenName" value="#{requestScope.twitterScreenName}"/>
</td>
</tr>
<tr>
<td>
<p:commandButton value="Add Account" actionListener="#{contactBean.addTwitterAccount(requestScope.twitterScreenName)}" styleClass="btn-blue" process="@form" update=":growl, :messageForm"/>
</td>
</tr>
</table>
そしてこれはバッキングビーンです
@Component
@Scope("session")
public class ContactBean implements Serializable {
private static String SOCIAL_MEDIA_ACCOUNTS_TEMPLATE_PARENT_DIRECTORY = "/templates/";
public void addTwitterAccount(String screenName){
//this contiains the implmentation
}
public String resolveTemplate(String socialMedia){
if(socialMedia.equalsIgnoreCase("Twitter")){
return SOCIAL_MEDIA_ACCOUNTS_TEMPLATE_PARENT_DIRECTORY + "twitter.xhtml";
}
if(socialMedia.equalsIgnoreCase("Facebook")){
return SOCIAL_MEDIA_ACCOUNTS_TEMPLATE_PARENT_DIRECTORY + "facebook.xhtml";
}
else if(socialMedia.equalsIgnoreCase("Google+")){
return SOCIAL_MEDIA_ACCOUNTS_TEMPLATE_PARENT_DIRECTORY + "googlePlus.xhtml";
}
return "";
}
}
このシナリオでは、templatesディレクトリの下にあるテンプレートの一部であるactionListenerを起動できません。JSF2.1.7とPrimefaces3.3を使用しています。