0

I am developing an ADF based project. The code below is a part of my View. I want to show a NUMBER value in the input text field which can be changed anyway. All I want is that value to be right aligned in the field. I have read that contentStyle="text-align:right; does the job, but the requirement is not to use it. I am wondering myself if the value is of type number and convertNumber is used in the code, should the value be right aligned automatically?

I will appreciate any help you give me!

 <af:inputText value="#{row.bindings.B.inputValue}"
           styleClass="class" simple="true"
           required="#{bindings.A.hints.B.mandatory}"
           maximumLength="#{bindings.A.hints.B.precision}"
           shortDesc="#{bindings.A.hints.B.tooltip}"
           id="bb" autoSubmit="true"
           disabled="#{viewScope.aBean.getSmth('abc')}"
           valueChangeListener="#{viewScope.aBean.onBChange}">
      <f:validator binding="#{row.bindings.B.validator}"/>
      <af:convertNumber groupingUsed="false"
      pattern="#{bindings.AA.hints.B.format}"/>
K. H.
  • 185
  • 1
  • 3
  • 19
  • _"I have read that `contentStyle="text-align:right;` does the job, but the requirement is not to use it."_ : **why???** – Kukeltje Jan 12 '16 at 16:56
  • The value in the input text is of type Number, I suppose that it should be right aligned automatically, because it is a number. Am I right? – K. H. Jan 12 '16 at 20:55
  • 1
    This is nowhere specified in HTML. Just do it yourself. – BalusC Jan 12 '16 at 21:07
  • I have input fields of type Long or Integer which are right aligned, by default, but the number input filed is not. Why? – K. H. Jan 12 '16 at 22:08
  • Here you use an inputText. And let guess, on the Long and Integer you use an something like inputNumber? – Kukeltje Jan 12 '16 at 23:47
  • Yes, all of the fields are of type input text. – K. H. Jan 13 '16 at 09:57
  • So in all cases you use an `af:inputText` and in the case of Long and Integer it **automagically** aligns them right, but not for a Number? It clearly is functionality that is build in the `af:inputText` then in a way that it adds some css (check client-side with a browser developer tool) and it is in no way plain jsf related. – Kukeltje Jan 13 '16 at 12:01

1 Answers1

0

Use AFFieldNumberMarker in styleClass property of af:inputText, It will right align your value

  • what is fundamentally different from using contentStyle like the OP did (does) not want to use? (beside the class vs style thing)? I get the impression OP is maybe doing a course and it is an assignment. Cannot imaging any other reason the usage of contentStyle would be 'forbidden' – Kukeltje Jan 14 '16 at 09:07
  • Don't know the reason but if OP doesn't want to use contentStyle then StyleClass is another option (If we talk about options) – Ashish Awasthi Jan 15 '16 at 11:48
  • Yes, but they fall (to me at least) in (almost) the same category. Hence my question (but that does not mean I think your answer is wrong, on the contrary) – Kukeltje Jan 15 '16 at 12:14