Is there any way to string JSF h:outPutTextValue ? my string is A-B-A03 ,i just want to display last 3 characters .does openfaces have any avialable function to do this ?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use a
Converterfor this job. JSF has several builtin converters, but no one suits this very specific functional requirement, so you’d need to create a custom one.It’s relatively easy, just implement the
Converterinterface according its contract:Provided that you’re using JSF 2.0 (your question history confirms this), you can use the
@FacesConverterannotation to register the converter. You can use the (default)valueattribute to assign it a converter ID:(where “something” should represent the specific name of the model value you’re trying to convert, e.g. “zipcode” or whatever it is)
so that you can reference it as follows:
For your particular functional requirement the converter implementation can look like this (assuming that you actually want to split on
-and return only the last part, which makes so much more sense than “display last 3 characters”):