Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimefaces and liferay: Single select not working
    primarykey
    data
    text
    <p>I'm following the example given at <a href="http://www.primefaces.org/showcase/ui/datatableRowSelectionSingle.jsf" rel="nofollow">http://www.primefaces.org/showcase/ui/datatableRowSelectionSingle.jsf</a></p> <p>I'm using this as a portlet in Liferay. Here is my code:</p> <p><strong>The HTML:</strong></p> <pre><code>&lt;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"&gt; &lt;h:form id="form"&gt; &lt;h:panelGrid columns="1" cellpadding="10" width="100%"&gt; &lt;p:dataTable id="campaignTable" var="data" value="#{campaign.allCampaigns}" selectionMode="single" rowKey="#{data.campaignId}" selection="#{campaign.selectedCampaign}"&gt; &lt;f:facet name="header"&gt; &lt;p:commandButton type="button" value="Create Campaign" icon="ui-icon-document" update=":form:createForm" onclick="createDialog.show()" /&gt; &lt;/f:facet&gt; &lt;p:column sortBy="#{data.campaignId}"&gt; &lt;f:facet name="header"&gt;ID&lt;/f:facet&gt; &lt;h:outputText value="#{data.campaignId}" /&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.carrier}"&gt; &lt;f:facet name="header"&gt;Carrier&lt;/f:facet&gt; &lt;h:outputText value="#{data.carrier}" /&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.shortCode}"&gt; &lt;f:facet name="header"&gt;Short Code&lt;/f:facet&gt; &lt;h:outputText value="#{data.shortCode}" /&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.sendType}"&gt; &lt;f:facet name="header"&gt;Send Type&lt;/f:facet&gt; &lt;h:outputText value="#{data.sendType}" /&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.startDate}"&gt; &lt;f:facet name="header"&gt;Start Date&lt;/f:facet&gt; &lt;h:outputText value="#{data.startDate.time}"&gt; &lt;f:convertDateTime pattern="MM/dd/yyyy hh:mm a" /&gt; &lt;/h:outputText&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.endDate}"&gt; &lt;f:facet name="header"&gt;End Date&lt;/f:facet&gt; &lt;h:outputText value="#{data.endDate.time}"&gt; &lt;f:convertDateTime pattern="MM/dd/yyyy hh:mm a" /&gt; &lt;/h:outputText&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.messageText}"&gt; &lt;f:facet name="header"&gt;Text Message&lt;/f:facet&gt; &lt;h:outputText value="#{data.messageText}" /&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.serviceId}"&gt; &lt;f:facet name="header"&gt;Service ID&lt;/f:facet&gt; &lt;h:outputText value="#{data.serviceId}" /&gt; &lt;/p:column&gt; &lt;p:column sortBy="#{data.responseKeyword}"&gt; &lt;f:facet name="header"&gt;Response Keyword&lt;/f:facet&gt; &lt;h:outputText value="#{data.responseKeyword}" /&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;/h:panelGrid&gt; &lt;p:dialog id="createDialog" header="Create Campaign" widgetVar="createDialog"&gt; &lt;h:panelGrid id="createForm" columns="2" cellpadding="5"&gt; &lt;h:outputLabel for="campaignId" value="Campaign ID:" /&gt; &lt;p:inputText value="#{campaign.selectedCampaign.campaignId}" id="campaignId" required="true" label="Campaign ID" /&gt; &lt;h:outputLabel for="startDate" value="Start Date:" /&gt; &lt;p:inputText value="#{campaign.selectedCampaign.startDate}" id="startDate" required="true" label="Start Date" /&gt; &lt;f:facet name="footer"&gt; &lt;p:commandButton id="createCampaignButton" value="Create" update=":growl" actionListener="#{campaign.createCampaign()}" /&gt; &lt;/f:facet&gt; &lt;/h:panelGrid&gt; &lt;/p:dialog&gt; &lt;/h:form&gt; &lt;/ui:composition&gt; </code></pre> <p><strong>And the backing bean:</strong></p> <pre><code>@ManagedBean @ViewScoped public class Campaign implements Serializable { private List&lt;CampaignBean&gt; allCampaigns; private CampaignBean selectedCampaign; public Campaign() { MyProxy proxy = new MyProxy(); try { CampaignsResponse response = proxy.getAllCampaigns(); if (response != null) { setAllCampaigns(new ArrayList&lt;CampaignBean&gt;(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&lt;CampaignBean&gt; getAllCampaigns() { return allCampaigns; } public void setAllCampaigns(List&lt;CampaignBean&gt; allCampaigns) { this.allCampaigns = allCampaigns; } public CampaignBean getSelectedCampaign() { return selectedCampaign; } public void setSelectedCampaign(CampaignBean selectedCampaign) { this.selectedCampaign = selectedCampaign; } } </code></pre> <p>The form is not populated with the selected row values!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload