简体   繁体   中英

Row selection and data processing in rich:extendedDataTable

I am working with JSF2.0 , Spring-Webflow2.3.1 and richfaces4.2.3 . I have got a rich:extendedDataTable which will show a list of data(There is no button present inside it). I need to implement ->

  • double click on a row to get the details in a separate screen.

  • Select a row and click on "View Details" button, which will also show me the details in the separate screen.

I am able to take out the row id, but i need to get the id field provided in the object to fetch the data. How will i make this possible using spring-webflow .

Here is a sample example as the second requirement
Select a row and click on "View Details" button, which will show the details in the separate screen.
I assume that

  1. Your pojo Class name is "YouPojoClass.java"
  2. Your pojo Class have (member1,member2,code) fields
  3. Your data set of extendedDataTable will be get from yourFirstController.rowVariableList "List of YouPojoClass"
  4. Your first page controller name " yourFirstController.java "
  5. Your second page name is " secondPage.xhtml "

// In your first page screen

<rich:extendedDataTable id="rowVariablepliersTable"
    value="#{yourFirstController.dataModel}" var="rowVariable">

    <rich:column width="300px">
        <f:facet name="header">
            <h:outputText value="member1" />            
        </f:facet>
        <h:outputText value="#{rowVariable.member1}" />
    </rich:column>

    <rich:column width="300px">
        <f:facet name="header">
            <h:outputText value="member2" />            
        </f:facet>
        <h:outputText value="#{rowVariable.member2}" />
    </rich:column>

    <rich:column width="90px">
        <f:facet name="header">
            <h:outputText value="view" />
        </f:facet>
        <h:commandButton 
            title="view" 
            value="view"
            action="#{yourFirstController.edit(rowVariable)}"/>
        </h:commandButton>
    </rich:column>
</rich:extendedDataTable>

// In your first page controller

public String view(YouPojoClass rowVariable) {      
    Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
    requestMap.put("SELECTED_ITEM_ID", rowVariable.getCode());  
    return "secondPage";
}  

// In your second page controller

public void postConstruct() {
    Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
    String SELECTED_ITEM_ID = requestMap.get("SELECTED_ITEM_ID");
    // .....
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM