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....

1
  • Have you tried wrapping your whole table in the form? Commented Sep 26, 2011 at 9:04

1 Answer 1

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) {
    // ...
}
Sign up to request clarification or add additional context in comments.

2 Comments

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
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 stackoverflow.com/questions/4994458/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.