gpt4 book ai didi

Primefaces 和 liferay : Single select not working

转载 作者:行者123 更新时间:2023-12-02 02:09:51 26 4
gpt4 key购买 nike

我正在按照 http://www.primefaces.org/showcase/ui/datatableRowSelectionSingle.jsf 给出的示例进行操作

我在 Liferay 中将其用作 portlet。这是我的代码:

HTML:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">

<h:form id="form">

<h:panelGrid columns="1" cellpadding="10" width="100%">

<p:dataTable id="campaignTable" var="data"
value="#{campaign.allCampaigns}" selectionMode="single"
rowKey="#{data.campaignId}" selection="#{campaign.selectedCampaign}">

<f:facet name="header">
<p:commandButton type="button" value="Create Campaign" icon="ui-icon-document" update=":form:createForm" onclick="createDialog.show()" />

</f:facet>

<p:column sortBy="#{data.campaignId}">
<f:facet name="header">ID</f:facet>
<h:outputText value="#{data.campaignId}" />
</p:column>

<p:column sortBy="#{data.carrier}">
<f:facet name="header">Carrier</f:facet>
<h:outputText value="#{data.carrier}" />
</p:column>

<p:column sortBy="#{data.shortCode}">
<f:facet name="header">Short Code</f:facet>
<h:outputText value="#{data.shortCode}" />
</p:column>

<p:column sortBy="#{data.sendType}">
<f:facet name="header">Send Type</f:facet>
<h:outputText value="#{data.sendType}" />
</p:column>

<p:column sortBy="#{data.startDate}">
<f:facet name="header">Start Date</f:facet>
<h:outputText value="#{data.startDate.time}">
<f:convertDateTime pattern="MM/dd/yyyy hh:mm a" />
</h:outputText>
</p:column>

<p:column sortBy="#{data.endDate}">
<f:facet name="header">End Date</f:facet>
<h:outputText value="#{data.endDate.time}">
<f:convertDateTime pattern="MM/dd/yyyy hh:mm a" />
</h:outputText>
</p:column>

<p:column sortBy="#{data.messageText}">
<f:facet name="header">Text Message</f:facet>
<h:outputText value="#{data.messageText}" />
</p:column>

<p:column sortBy="#{data.serviceId}">
<f:facet name="header">Service ID</f:facet>
<h:outputText value="#{data.serviceId}" />
</p:column>

<p:column sortBy="#{data.responseKeyword}">
<f:facet name="header">Response Keyword</f:facet>
<h:outputText value="#{data.responseKeyword}" />
</p:column>

</p:dataTable>
</h:panelGrid>


<p:dialog id="createDialog" header="Create Campaign" widgetVar="createDialog">

<h:panelGrid id="createForm" columns="2" cellpadding="5">
<h:outputLabel for="campaignId" value="Campaign ID:" />
<p:inputText value="#{campaign.selectedCampaign.campaignId}" id="campaignId" required="true" label="Campaign ID" />

<h:outputLabel for="startDate" value="Start Date:" />
<p:inputText value="#{campaign.selectedCampaign.startDate}" id="startDate" required="true" label="Start Date" />

<f:facet name="footer">
<p:commandButton id="createCampaignButton" value="Create" update=":growl" actionListener="#{campaign.createCampaign()}" />
</f:facet>
</h:panelGrid>
</p:dialog>

</h:form>

</ui:composition>

和辅助 bean:

@ManagedBean
@ViewScoped
public class Campaign implements Serializable {

private List<CampaignBean> allCampaigns;
private CampaignBean selectedCampaign;

public Campaign() {
MyProxy proxy = new MyProxy();
try {
CampaignsResponse response = proxy.getAllCampaigns();
if (response != null) {
setAllCampaigns(new ArrayList<CampaignBean>(Arrays
.asList(response.getCampaigns())));
}
} catch (RemoteException e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Error",
"Problem listing campaigns"));
}
}

public void createCampaign() {

}


/* Getters and Setters */
public List<CampaignBean> getAllCampaigns() {
return allCampaigns;
}

public void setAllCampaigns(List<CampaignBean> allCampaigns) {
this.allCampaigns = allCampaigns;
}

public CampaignBean getSelectedCampaign() {
return selectedCampaign;
}

public void setSelectedCampaign(CampaignBean selectedCampaign) {
this.selectedCampaign = selectedCampaign;
}


}

表单未填充选定的行值!

最佳答案

我终于明白问题出在哪里了。整个表格都在“TabView”组件中。我使用了错误的选择器,而不是使用 update=":form:createForm" 我应该使用 update=":tabView:form:createForm" 并删除 type="button" 声明。

关于Primefaces 和 liferay : Single select not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13406280/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com