Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:37:18+00:00 2026-06-10T11:37:18+00:00

Is there any way to string JSF h:outPutTextValue ? my string is A-B-A03 ,i

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:37:19+00:00Added an answer on June 10, 2026 at 11:37 am

    You could use a Converter for 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 Converter interface according its contract:

    public class MyConverter implements Converter {
    
        @Override
        public String getAsString(FacesContext context, UIComponent component, Object modelValue) throws ConverterException {
            // Write code here which converts the model value to display value.
        }
    
        @Override
        public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) throws ConverterException {
            // Write code here which converts the submitted value to model value.
            // This method won't be used in h:outputText, but in UIInput components only.
        }
    
    }
    

    Provided that you’re using JSF 2.0 (your question history confirms this), you can use the @FacesConverter annotation to register the converter. You can use the (default) value attribute to assign it a converter ID:

    @FacesConverter("somethingConverter")
    

    (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:

    <h:outputText value="#{bean.something}" converter="somethingConverter" />
    

    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”):

    @FacesConverter("somethingConverter")
    public class SomethingConverter implements Converter {
    
        @Override
        public String getAsString(FacesContext context, UIComponent component, Object modelValue) throws ConverterException {
            if (!(modelValue instanceof String)) {
                return modelValue; // Or throw ConverterException, your choice.
            }
    
            String[] parts = ((String) modelValue).split("\\-");
            return parts[parts.length - 1];
        }
    
        @Override
        public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) throws ConverterException {
            throw new UnsupportedOperationException("Not implemented");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so is there any way to do it. i want to put a string
Is there any way to check String reference from String.xml I have many String
Is there any way to have a random string in a Django template? I
Is there ANY way of monitoring primitive String declaration in NodeJS? For example, when
Is there any way to decrypt the encrypted MD5 string, given the key?
Is there any way to create a new NSString from a format string like
Is there any way InputStream wrapping a list of UTF-8 String ? I'd like
Is there any simple way how to initialize String in Objective-C with int such
Is there any better way to get take a string such as (123) 455-2344
is there any other way to know if the java String contains character-encoding in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.