0

I am using PrimeFaces 5.2 and at a place in my web app. I am displaying a data table is which corresponding to each row. I am giving an edit link (<p:commandLink>) to edit the the fields of corresponding entity on next page but the link is not working at all. Here is the XHTML content.

<p:dataTable id="tickets" var="ticket"
        value="#{ticketController.ticketModels}" paginator="true" rows="10"
        filteredValue="#{ticketController.filteredTickets}">

        <p:column headerText="Ticket Id" sortBy="#{ticket.ticketId}">
            <p:commandLink action="viewDetailedTicket">
                <h:outputText value=" #{ticket.ticketId}"></h:outputText>
            </p:commandLink>
        </p:column>

        <p:column headerText="Summary" filterBy="#{ticket.summary}"
            filterMatchMode="contains" sortBy="#{ticket.summary}">
            <h:outputText value="#{ticket.summary}" />
        </p:column>

        <p:column headerText="Priority">
            <h:outputText value="#{ticket.priority}" />
        </p:column>
.
  ...............................
</p:dataTable>

The following is my backing bean:

@ManagedBean
public class TicketController {
    @ManagedProperty(value = "#{ticketpojo}")
    private Ticket ticket;
    private TicketDao tDao;
    private TicketModel ticketModel;

    public TicketModel getTicketModel() {
        return ticketModel;
    }

    public void setTicketModel(TicketModel ticketModel) {
        this.ticketModel = ticketModel;
    }

    public TicketController() {
        tDao = new TicketDao();
    }

    public String viewDetailedTicket() {
         ticketModel = tDao.getTicket(ticketId);
        return "viewDetailedTicket";
    }
}

When I hover, over the link , the tooltip at the bottom of the browser shows http://localhost:8080/JSF_1/view/viewTicket.xhtml# , a '#' is appended to the end of the current page URL. When clicked it remains on the same page. I have tried putting the link outside the data-table that also didn't work .

Tiny
  • 27,221
  • 105
  • 339
  • 599
Alok Mishra
  • 926
  • 13
  • 39

1 Answers1

2

A commandLink or any action that you'd like to do with JSF/primefaces must be inside a form. Otherwise no HTTP Post can be performed. I suggest to use one form for the whole datatable. Otherwise there will be a lot of forms for the multiple rows.

GregD
  • 1,884
  • 2
  • 28
  • 55