SelectOneMenu updating another attribute

jQuery UI Widgets
Post Reply
simteq
Posts: 23
Joined: 02 Aug 2016, 11:59

12 Aug 2016, 11:15

Hi
I have a selectOneMenu item which is used to select a credit rating agency ie:
<h:outputLabel value="Credit Rating Source:* " styleClass="default-label"/>
<p:selectOneMenu value="#{counterpartyBean.counterparty.ratingSource}" styleClass="default-input"
valueChangeListener="#{counterpartyBean.ratingSourceChanged}" update="creditRating">
<f:selectItem itemLabel="Not Specified" itemValue="NS"/>
<f:selectItem itemLabel="Fitch" itemValue="FT"/>
<f:selectItem itemLabel="Moodys" itemValue="MDY"/>
<f:selectItem itemLabel="Standard and Poors" itemValue="SP"/>
</p:selectOneMenu>

which I want to use to change the available values for credit ratings in another selectOneMenu ie:

<h:outputLabel value="CreditRating:* " styleClass="default-label"/>
<p:selectOneMenu id="creditRating" value="#{counterpartyBean.counterparty.creditRating}" styleClass="default-input"
valueChangeListener="#{counterpartyBean.creditRatingChanged}" update="pd">
<f:selectItems value="#{counterpartyBean.ratings}" />
</p:selectOneMenu>

This idea does not seem to work, any suggestions please

simteq
Posts: 23
Joined: 02 Aug 2016, 11:59

12 Aug 2016, 11:29

Quick update, i have replaced the valueChangedListener to

<p:ajax listener="#{counterpartyBean.ratingSourceChanged}" />

as I am not interested in the old value and I do not want to submit the complete form at this stage, the ratingSourceChanged method is now getting called but the credit rating menu items are still not being updated

simteq
Posts: 23
Joined: 02 Aug 2016, 11:59

13 Aug 2016, 08:38

Just to recap: I wanted a change to a p:selectOneMenu to update the list of values for anothe p:selectOneMenu immediately after a change to the first without waiting for the form to be submitted so finally cracked it:

Code: Select all


<h:outputLabel value="Credit Rating Source:* " />
<p:selectOneMenu value="#{counterpartyBean.counterparty.ratingSource}" >								                        
		<f:selectItem itemLabel="Not Specified" itemValue="NS"/>
		<f:selectItem itemLabel="Fitch" itemValue="FT"/>
		<f:selectItem itemLabel="Moodys" itemValue="MDY"/>
		<f:selectItem itemLabel="Standard and Poors" itemValue="SP"/>
		<p:ajax listener="#{counterpartyBean.ratingSourceChanged}" update="creditRating"/> 
</p:selectOneMenu>

<h:outputLabel value="CreditRating:* "  />
<p:selectOneMenu id="creditRating" value="#{counterpartyBean.counterparty.creditRating}" >														
		<f:selectItems value="#{counterpartyBean.ratings}" />
		<p:ajax listener="#{counterpartyBean.creditRatingChanged}" update="pd"/>

</p:selectOneMenu>

<h:outputLabel value="Probability of Default 0-100%: "  />
<h:inputText id="pd" value="#{counterpartyBean.counterparty.pd}"  size="8">
		<f:convertNumber pattern="##0.0000"/>
</h:inputText>
So now, when the first selectOneMenu vakue changes, the list of ratings changes in the second and when that changes the pd value changes.

Post Reply

Return to “PrimeUI”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests