1
votes

i got two cases of strange behaviour in my p:dataTable . First when i try to call the h:link with the f:param the link always sends the same id. Always the id from the first entry. The bigger problem is when i push on the commandbutton the h:link gets called though this behavior was completely not expected. Especially without the right Parameters. Is this a Bug or am i doing something wrong? When i delete the h:link everything works like expected. I would appreciate any help in this matter

My Primefaces Version is 3.5 and im working with Liferay 6.1 on Tomcat 7. With the newest FacesBridge

<h:form id="serviceForm">
     <p:dataTable id="newServicesTable" var="service" value="#{cloudServicesBean.newServices}" rowKey="service.serviceId" selection="#{cloudServicesBean.selectedService}">
                <p:column headerText="Servicename">
                 <h:link  outcome="/views/cloudservice/overview.xhtml" includeViewParams="true" value="#{service.serviceName}">
                        <h:outputText value="#{service.serviceId}"/>
                         <f:param name="selectedServiceId" value="#{service.serviceId}" />
                    </h:link>   
                </p:column>
                <p:column headerText="Provider">
                    <h:outputText value="#{adminBean.getOrganizationNameForId(service.providerId)}" />
                </p:column>
                <p:column headerText="Datum">
                    <h:outputText value="#{service.createDate}" />
                </p:column>
                <p:column headerText="Aktionen" rendered="#{adminBean.isUserAdministrator()}">
                    <p:commandButton icon="ui-icon-check"  action="#{cloudServicesBean.setServiceApproved}" update=":serviceForm">
                        <f:setPropertyActionListener value="#{service}" target="#{cloudServicesBean.selectedService}" />
                    </p:commandButton>

            </p:column>
            </p:dataTable>
1
You can try rowIndexVar="index" instead rowKey then pass the value via f:param value="#{index}"`. This should fix the set first element problem. - Ömer Faruk Almalı
Unless you mistyped that, you must include an EL expression in your rowKey attribute. That means #{service.serviceId} instead of service.serviceId. The second issue I can see is that you're giving h:link a value and also putting h:outputText inside, which is basically redundant. - Xtreme Biker
when i use index, the value is always 0, also the redundancy didnt help. I always get the same selectedServiceId. Suprisingly the outputText with the serviceId is correct. but not the Param which is always the same id. Even if i put a hard coded param parameter in another column with i fix id it has the same id like every other param valued :( - Andreas Reidt

1 Answers

1
votes

I had exactly the same problem. I run Primefaces 3.5 with Liferay 6.0.11 on Tomcat 7. When I switched the Liferay JSF dependencies from version 3.1.2.ga3 to 3.1.3-ga4 the issue was resolved.

      <dependency>
        <groupId>com.liferay.faces</groupId>
        <artifactId>liferay-faces-alloy</artifactId>
        <version>3.1.3-ga4</version>
      </dependency>
      <dependency>
        <groupId>com.liferay.faces</groupId>
        <artifactId>liferay-faces-bridge-impl</artifactId>
        <version>3.1.3-ga4</version>
      </dependency>
      <dependency>
        <groupId>com.liferay.faces</groupId>
        <artifactId>liferay-faces-portal</artifactId>
        <version>3.1.3-ga4</version>