0

Hello EveryOne well this is an example of my lazy dataTable , so when i click the command link to view the item detail on another page the load method invoked , I want only to go to the detail page without invoking load method - because my data is not changed so there is no need to request database.

<h:form id="form"> 
        <div class="card">
    <p:dataTable id="table" var="car" value="#{carBean.lazyCars}" widgetvar="wVar" lazy="true" 
    selection="#{carBeans.selectedCar}" selectionMode="single" rowKey="#{car.id}">
                <p:column headerText="Code">
                    <h:outputText value="#{product.code}" />
                </p:column>
    
                <p:column headerText="Name">
                    <h:outputText value="#{product.name}" />
                </p:column>
    
               <p:column headerText="action">
                   <p:commandLink ajax="false" target="_blank" action="carBeans.details()"
onclick="PF('wVar').unselectAllRows();PF('wVar').selectRow($(this).parents('tr:first'));">
<f:setPropertyActionListener value="#{car}" 
target="#{carBeans.selectedCar}"/>
                   </p:commandLink>
                </p:column>
    </p:dataTable>
        </div>
    </h:form>
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102

1 Answers1

0

How will this work if you select a car, a new browser tab is opened, you come back to the overview and select a different car? I would keep the UI restricted to a single browser window to prevent selecting different entities and it will allow to use @ViewScoped on the bean instead of @SessionScoped.

Then, there is no need to set the selected entity using an action as

<p:dataTable selection="#{carBeans.selectedCar}" .../>

already takes care of it.

See also:

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102