0

i want to populate both label and value in the input text field by storing them into bean.

i have tried using map which gives me only value to store into bean how can i also store label into bean and populate to input text field

-->
                    <div  id = "buttonID" style = "display :block;">

                    <p:selectOneMenu id="selectformName" value="#{tformBean.formName}" >

                        <f:selectItem itemLabel="Select Category.. " itemValue=" " />
                        <f:selectItems value="#{tformServices.getDistinctTformName()}" />   
                        <p:ajax  update="formNameid formid" partialSubmit="true"/>
                        <!-- <p:ajax  event ="change"   listener = "tformServices.submitA(tformBean.formID)" update="formNameid" partialSubmit="true"/> -->
                    </p:selectOneMenu>
                    <br></br>

                   <p:commandButton  value="ADD DATA TO CATEGORY"  process= " formNameid" style="margin-right:20px;"  styleClass="ui-priority-primary" onclick ="hideshowAddCat();"> 

                   </p:commandButton> 


            <div class="ui-g-12 ui-lg-4" style="background:#f2f2f2;margin-top:15px;">                              
            <div class="card card-w-title">
            <label for="formid">FORM_ID<i class="fa fa-asterisk" style="color: red;"></i></label>
                <p:panelGrid columns="1" layout="grid" styleClass="ui-panelgrid-blank form-group">
                     <p:inputText id="formid" placeholder="FORM_ID" value="#{tformBean.formID}" required = "true">
                     </p:inputText>
                </p:panelGrid>    
            </div>
            </div>

            <div class="ui-g-12 ui-lg-4" style="background:#f2f2f2;margin-top:15px;">                              
            <div class="card card-w-title">
            <label for="formNameid">FORM_NAME<i class="fa fa-asterisk" style="color: red;"></i></label>
                <p:panelGrid columns="1" layout="grid" styleClass="ui-panelgrid-blank form-group">
                     <p:inputText id="formNameid" placeholder="FORM_NAME" value="#{tformBean.formName}" required = "true">
                     </p:inputText>
                </p:panelGrid>    
            </div>

it results in storing only one value into bean

GOTBBST
  • 1
  • 1
  • Your java code is in no way related to the xhtml. So your problem is unclear. – Kukeltje Aug 30 '19 at 13:56
  • how about now @Kukeltje – GOTBBST Aug 30 '19 at 14:16
  • Not really an improvement. You state you want to populate something in an inputext but therere is no inputtext... If you want our help and don't want to waste our time, please take the [tour] again and read about[ask] and [mcve] and in addition read https://www.stackoverflow.com/tags/jsf/info. – Kukeltje Aug 30 '19 at 15:02
  • Oh and a select **_IS_** for storing one value. That is just how the component works, not only in JSF but in plain html and any js framework. – Kukeltje Aug 30 '19 at 15:04
  • Oh and the LABEL is something you have on the server side (YOU populate it) so based on the value, look up the label again and use it... There is a duplicate of this Q btw. I'll find it – Kukeltje Aug 30 '19 at 15:13

0 Answers0