Question
I am learning Jsf.Is there any method for making the spinners read only?I should change the value only using spinners and not directly typing the number.Can i implement that by setting attribute in the spinners.tld file?
Solution
With JSF2.0, you could write your own spinner JSF component except that, instead of using:
<h:inputText id="number" value="#{compositeComponent.attrs.value}"/>
(which is a read-write input box ), you could use a outputLabel
:
<h:outputLabel for="number" value="#{compositeComponent.attrs.value}"/>
, hence achieving exactly what you are after.
Note, an outputText
could be as effective.
JSF2.0 is released in PR (Public Review) mode.
It is worth looking into because one of the "pain points" for JSF has always been the complexity that you face in creating components. In JSF 2.0, creating a new component that's made up of existing components is a snap.
OTHER TIPS
Disabling the textfield part of a spinner control is a usability disaster. Please don’t do it. Some of us really want to enter the number.