-2

I have one label field which is license and I want give two license numbers for this..how to give two values here. I have one properties file (manageprofile) and one java class (manageprofiledatabean) which contains the license values

<h:outputLabel value="#('label.manageprofile.license')"/>

    <h:outputText value="#{manageProfileDataBean.license}"  />

    &nbsp;&nbsp;

    <h:outputText escape="false" value="&nbsp;&nbsp;"></h:outputText>
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Trying to clarify things: `manageprofile` is a [Resource Bundle](http://www.mkyong.com/jsf2/jsf-2-0-and-resource-bundles-example/)? And what's the name of the second license value field? – mabi Dec 18 '13 at 22:13

2 Answers2

0

firstly, h:outputLabel is meant to be used for labelling input controls - it renders as the html <label> tag(e.g.)

<h:outputLabel for="myname" value="#{bean.labelValue}" />
<h:inputText id="myname" value="#{bean.name} />

If you need to specify multiple values in expression language you can do so like this:

<h:outputText value="#{bean.property1 bean.property2}"/>

so I guess in your case you would write it as

<h:outputText value="#{'label.manageprofile.license' manageProfileDataBean.license}" />

Finally, you don't need to use an h:outputText if you're not referenceing any propery so the last pair of nbsp characters don;t need to be in in outputText tag at all.

Steve Atkinson
  • 1,219
  • 2
  • 12
  • 30
  • 2
    Your EL isn't valid. There's no `#()`, and your property access probably should be `#{bean.property1} #{bean.property2}`. – mabi Dec 18 '13 at 21:52
  • nope, you don't have to use expressions for value, plain text is just fine - unusual, but fine - try it yourslf. The second point is also incorrect you can concatebtate properties inside the #{} syntax. – Steve Atkinson Dec 18 '13 at 21:56
  • We *are* talking about JSR-245 EL? Maybe you intended to write `bean.property1 + bean.property2`? And I'm aware of composite expressions, it's just that `#()` or `#(}` aren't legal EL expressions. – mabi Dec 18 '13 at 22:10
  • Fixed the ( typo and updated the label example to be more realistic. You can use the + operator but it isn't necessary! I tested on tomcat 7 with standard reference jsf implementation and it works – Steve Atkinson Dec 19 '13 at 19:10
  • Actually, [you can't in – mabi Dec 19 '13 at 20:12
0

Concat both values in one string variable of manageProfileDataBean and then set it in

public class ManageProfileDataBean{

private String license = "";
private String val1 = "val1":
private String val2 = "val2";

public ManageProfileDataBean(){
      license = val1+val2;
}

//setter getter

}
Waqas Ahmed
  • 4,801
  • 3
  • 36
  • 45