1

When I click on <h:commandButton> (without selecting item from <h:selectOneMenu>), I'm able to invoke method of bean which redirects me to same page as well as server side validations works perfectly.

However, when I select item from <h:selectOneMenu>, it will render input text and <h:selectOneMenu> components dynamically via <f:ajax> and after that click on <h:commandButton>, I'm not able to invoke bean method as well as server side validations.

I also tried <c:forEach> instead of <ui:repeat>.

<h:form id="prodForm" enctype="multipart/form-data" role="form" class="form-horizontal" > 

    <div class="form-group">
        Product Name:
        <input type="text" class="form-control" style="#{component.valid? 'border-color:':'border-color:red;'}" 
               value="#{clientProCtr.cpm.prodName}"
               id="prod_name" jsfc="h:inputText" required="true" 
               requiredMessage="Product name Required" 
               validatorMessage="Product Name should be between 3 to 50 characters">
            <f:validateLength minimum="3" maximum="50"/>
        </input>
        <h:messages style="color: red;" class="list-unstyled" for="prod_name" />
    </div>

    <div class="col-lg-6">
        <h:selectOneMenu id="select_category" required="true" requiredMessage="Please select a category" value="#{clientProCtr.selectedCat}" >
            <f:selectItem itemLabel="--Select Category--" noSelectionOption="true" /> 
            <f:selectItems value="#{clientProCtr.clientCat}" var="i" itemValue="#{i.catMasId}" itemLabel="#{i.catName}" /> 
            <f:ajax event="change" 
                execute="@this" 
                render="featureList"
                listener="#{clientProCtr.displayFeatures()}" />
        </h:selectOneMenu>
        <h:message style="color: red;" class="list-unstyled" for="select_category" />
    </div>

    <h:panelGroup id="featureList">    
        <ui:repeat value="#{clientProCtr.clientFeatures}" var="j">
        <div class="form-group col-lg-6">
            <div class="form-group">
                <label class="col-lg-4 control-label" for="required">#{j.featureLabel}</label>
                <div class="col-lg-4">
                    <input type="text" class="form-control" id="required" alt="textValue" jsfc="h:inputText" />
                </div>
                <div class="col-lg-4">
                    <h:selectOneMenu class="12">
                        <f:selectItem itemValue="0" itemLabel="--Select Unit--"></f:selectItem>
                        <f:selectItems value="#{clientProCtr.displayUnits(j.featureMasId)}" var="k" itemValue="#{k.unitFeatureId}" itemLabel="#{k.unitName}"></f:selectItems>
                    </h:selectOneMenu>
                </div>
            </div>
        </div>
        </ui:repeat>
    </h:panelGroup>

    <div class="col-lg-1" style="float: right">
        <h:commandButton id="btnAdd" class="btn btn-info nostyle" value="Add" action="#{clientProCtr.addProduct()}" />
        <div class="marginB10"></div>
    </div><!-- End .span4 -->
</h:form>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I hope you got my problem. Please help me. I'm trying this thing since a week. If you would like to see the screenshots then also I can. – Shreyank Shah Feb 24 '15 at 14:27
  • Code is not in [MCVE](http://stackoverflow.com/help/mcve) format, and therefore I'm not really motivated to wade through all the noise and make educated guesses as to the actual model, so here's just a link http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked/2120183#2120183 Make sure you've excluded at least #3 and #4. – BalusC Feb 24 '15 at 14:33

0 Answers0