Board index JavaServer Faces General Spinner with dynamic max value

Spinner with dynamic max value

Components, Ajax Framework, Utilities and More.

Post 08 Feb 2011, 20:31

Posts: 6
I am trying to create a spinner with a dynamic max value. Each time the spinner's value changes, I calculate a new maximum value for it.

<p:spinner value="#{filesList.transitionTime}" min="1" max="#{filesList.maxValue}" id="timeline_transition_time" valueChangeListener="#{filesList.transitionTimeChangeListener}">
                        <f:ajax execute="timeline_transition_time" render="timeline_total_duration"/>
                    </p:spinner>

<h:panelGroup id="timeline_total_duration" layout="block">
...
</h:panelGroup>


Although in my backing bean FilesList I am able to set a maximum value correctly in the transitionTimeChangeListener, I can't update it in the view using Ajax (I know I could use onchange="submit()" but I don't want to submit the form everytime I change the spinner's value).

Any idea on how I could solve this problem?


Posts: 15043
Location: Cybertron

max property is read only once when component is initialized, so server side changes are not reflected since you dont update client side. Updating spinner itself will probably help.
PrimeFaces Lead


Posts: 6
I had already tried to update spinner itself by inserting its id in the list of values of the f:ajax render attribute, like this:

<p:spinner value="#{filesList.transitionTime}" min="1" max="#{filesList.maxValue}" id="timeline_transition_time" valueChangeListener="#{filesList.transitionTimeChangeListener}">
                        <f:ajax execute="timeline_transition_time" render="timeline_total_duration timeline_transition_time"/>
                    </p:spinner>


But everytime I change the spinner's value, it shows an "undefined" string:

Image

Was this your solution or did I misurderstand?


Posts: 6
Any idea?


Return to General