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

  • Home
  • SEARCH
  • 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 6976857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:33:03+00:00 2026-05-27T17:33:03+00:00

I am trying to pass an object from one page to another page where

  • 0

I am trying to pass an object from one page to another page where each page is in a different view.

On the first page I have an input text, where myBean is a ViewScoped Bean and name is an object.
<h:inputText value="#{myBean.name}"/>

The second page contains,
<f:metadata>
<f:viewParam name="userId" value="#{myBean.name}"/>
</f:metadata>

I get the error Conversion Error setting value mypackage.myBean@257100b’ for ‘null Converter’.
Can we pass objects other than String values to view parameters?

  • 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-05-27T17:33:03+00:00Added an answer on May 27, 2026 at 5:33 pm

    Yes, you can. You just have to supply a converter which converts between the string representation of the object type behind #{myBean.name} and the real object. The string representation is usually the unique technical/natural identifier of the object in question. For example, the table’s PK. It has got to be a string, simply because HTTP request parameters can be strings only. You can’t pass complex Java objects around in URLs. URLs are just strings.

    Here’s a kickoff example:

    E.g. the following in the initial view:

    <h:link value="Edit" outcome="edit">
        <f:param name="id" value="#{personViewer.person.id}" />
    </h:link>
    

    (which generates an <a href="edit.xhtml?id=123">Edit</a>)

    and the following in the linked view:

    <f:metadata>
        <f:viewParam name="id" value="#{personEditor.person}"
            converter="#{personConverter}" converterMessage="Bad request. Unknown person."
            required="true" requiredMessage="Bad request. Please use a link from within the system."
        />
    </f:metadata>
    <h:messages />
    

    with this converter

    @ManagedBean
    @RequestScoped
    public class PersonConverter implements Converter {
    
        @EJB
        private PersonService personService;
    
        @Override
        public String getAsString(FacesContext context, UIComponent component, Object value) {
            return String.valueOf(((Person) value).getId());
        }
    
        @Override
        public Object getAsObject(FacesContext context, UIComponent component, String value) {
            return personService.find(Long.valueOf(value));
        }
    
    }
    

    (oversimplified; all null/number checks omitted, but you got the idea)

    See also:

    • Communication in JSF 2.0 – Converting and validating GET request parameters

    Update as per the comments, you actually want to fire a POST request. You don’t need a <f:viewParam> at all. It’s for setting/validating/converting GET request parameters only. Attempting to serialize the whole object makes also no utter sense. Just use @ManagedProperty.

    E.g.

    @ManagedBean
    @ViewScoped
    public class PersonEditor implements Serializable {
    
        @ManagedProperty("#{personViewer.person}")
        private Person person;
    
        // ...
    }
    

    It’s only not bookmarkable anymore and not SEO-friendly (but that’s the nature of POST, you’re probably already for long aware of this). Note that the #{personViewer} bean must by itself also be @ViewScoped (and thus not @ReqestScoped). You also need to make sure that you don’t navigate back with a redirect, but just a forward.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass a struct from one object to another. I have the
I'm trying to pass an object from one controller action to another. The object
I'm trying to pass a business object from one WinForm to another WinForm for
I'm trying to pass a list from one form class to another. Here's the
I'm trying to pass post data from one page to the next but PreviousPage
I'm trying to pass a variable from one function to another, but the var
I'm trying to pass an ArrayList from my first Activity to the next one.
What are some streamline ways to pass objects from one PHP page to another?
In javascript, I have an object that I am trying to pass but not
I am using Querystring to pass values from one page to other. I am

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.