0

I'm using JSF 2.0 and trying to display a list of data using a datatable. After my data is fetched I have button in each row, on this button it has to take some of the fields as input parameters and then save it.

<h:dataTable id="dt1" value="#{vendorApp.editQtnList}" var="qList" >
 <h:column>
  <f:facet name="header">
   <h:outputText style=""value="RFQ Number" />
  </f:facet>     
<h:column>
<f:facet name="header"> 
 <h:outputText value="Vendor Number"/>
</f:facet> 
<h:outputText value="#{qList.vendorNumber}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
 <h:outputText value="RFQ Date"/>
</f:facet>
<h:outputText value="#{qList.rfqDate}"></h:outputText> 
</h:column>
<h:column> 
<f:facet name="header">
 <h:outputText value=""/>
</f:facet>
<h:inputText id="adComment" value="#{qList.adminComment}"></h:inputText>
</h:column>
<h:column> 
<f:facet name="header">
 <h:outputText value=""/>
</f:facet>
<h:form>
 <h:commandButton id="rejectBtn" value="Reject" action="#{vendorApp.rejectEditQuotation}">
 <f:param name="vendorNum" value="#{qList.vendorNumber}" />
 <f:param name="rfqNum" value="#{qList.rfqNumber}" />
 <f:param name="adComment" value="#{qList.adminComment}" /> 
</h:commandButton></h:form> </h:column> </h:dataTable>

In my above code, editQtnList is the getter method for list which gives a list fetched from database.Now user can click on reject by proving a comment in the text box provided, I have tried this as shown but the value of the comment is not feteched..Need suggestions on this....

Mango
  • 650
  • 2
  • 16
  • 38

1 Answers1

1

All input fields of interest must be placed inside the same form as the submit button.

Rewrite your view as follows:

<h:form>
    <h:dataTable value="#{vendorApp.quotations}" var="quotation">
        ...
        <h:column> 
            <h:inputText value="#{quotation.adminComment}" />
        </h:column>
        <h:column> 
            <h:commandButton value="Reject" action="#{vendorApp.rejectEditQuotation(quotation)}" />
        </h:column>
    </h:dataTable>
</h:form>

with

public void rejectEditQuotation(Quotation quotation) {
    // ...
}
Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you for the reply...u have suggested to use public void rejectEditQuatation(Quotation quotation), can u please confirm me if the Quotation in the arg list is the respective bean or...??? slightly confused kinldy help me – Mango Sep 26 '11 at 17:03
  • Yes, it is. Based on your question history you're using Java EE 6 / Servlet 3.0 (which comes along with EL 2.2 which supports passing method arguments), so this should work for you. See also http://stackoverflow.com/questions/4994458/how-can-i-pass-a-parameter-to-a-commandlink-inside-a-datatable – BalusC Sep 26 '11 at 17:04