user3331963
user3331963

Reputation: 13

how to edit single row in rich:dataTable

i have to edit a row in a table using rich faces 4 and modal panel. I am new one so please tell me in details and i know to make a table in rich faces. i already searched so many things but not getting any fruitful

Upvotes: 1

Views: 775

Answers (1)

Vasil Lukach
Vasil Lukach

Reputation: 3728

See answer for question "Richfaces: show details in popup [commandbutton, action and popupPanel]". It works in RichFaces 4.x with rowClick.

Or here is example with commandLink:

    <a4j:commandLink action="#{actionBean.setupTransactionDetails}"
        event="onclick" render="transactionDetails"
        oncomplete="#{rich:component('transactionDetails')}.show()"
        styleClass="rich-link">
        <h:outputText value="#{res.transactionType}" />
            <f:setPropertyActionListener value="#{res.transactionId}"
                target="#{profile.transactionId}" />
    </a4j:commandLink>

But I prefer updated version like this:

    <a4j:jsFunction name="showDetail" action="#{actionBean.setupTransactionDetails}"
    oncomplete="#{rich:component('transactionDetails')}.show();"
    render="transactionDetails">
        <a4j:param name="id" assignTo="#{profile.transactionId}"
            converter="javax.faces.Long" />
    </a4j:jsFunction>

    <rich:dataTable id="txnTable" rows="#{referenceData.recordsPerPage}"
    style="width: 100%" rowClasses="oddrow, evenrow"
    value="#{profile.transactions}" var="res" sortMode="single">
        <h:column width="110">
            <f:facet name="header">
                <h:outputText value="#{msg.transactionType}" />
            </f:facet>
            <a4j:commandLink onclick="showDetail('#{res.transactionId}');"
                value="#{res.transactionType}" />
        </h:column>
    </rich:dataTable>

    <rich:popupPanel id="transactionDetails" autosized="true"
        style="max-height:600px;">
        <!-- f:facet name="header" and f:facet name="controls" here -->
        <h:form id="transactionDetailsForm">
            <!-- some details here -->
        </h:form>
    </rich:popupPanel>

Profile backing bean

private Long transactionId; // + getter and setter

Action backing bean

    public void setupTransactionDetails() {
        Transaction txn = DAO.getInstance().get(Transaction.class, getProfile().getTransactionId());
        transactionForm.setup(txn);
    }

In case if you use EL 2.2 (or higher) you can call action bean method with parameter.

Upvotes: 1

Related Questions