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 7039379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:47:28+00:00 2026-05-28T01:47:28+00:00

i’m using prettyfaces 3.3.2 and JSF 2.2.1. i want to convert pretty url string

  • 0

i’m using prettyfaces 3.3.2 and JSF 2.2.1. i want to convert pretty url string to entity object and use the object in the web page. pretty-config.xml:

<url-mapping id="country">
    <pattern value="/country/#{countryBean.selectedCountry}">
        <convert param="#{countryBean.selectedCountry}" converterId="countryConverter" converterClass="Test.CountryBean" />
    </pattern>
    <view-id value="/faces/countries/country.xhtml" />
</url-mapping>

country.xhtml:

<f:metadata>
    <f:viewParam name="country" value="#{countryBean.selectedCountry}">
        <f:converter converterId="countryConverter" />
    </f:viewParam>
</f:metadata>
<ui:define name="content">
    #{countryBean.selectedCountry.country}
</ui:define>

CountryConverter:

public static EntityCountry country = new EntityCountry();

EntityManagerFactory emf = Persistence.createEntityManagerFactory("testPU");

public EntityCountry getAsObject(FacesContext context, UIComponent component, String value) {
    EntityManager em = emf.createEntityManager();

    Query query = em.createQuery("SELECT c FROM EntityCountry c WHERE c.url = :countryUrl")
            .setParameter("countryUrl", value);
    country = (EntityCountry) query.getSingleResult();
    return country;
}

public String getAsString(FacesContext context, UIComponent component, Object value) {
    EntityCountry c = (EntityCountry) value;
    return c.getUrl();
}

i toggle breakpoint to getAsObject method but it does not hit the breakpoint. faces-config.xml:

<converter>
    <converter-id>countryConverter</converter-id>
    <converter-class>Test.CountryConverter</converter-class>
</converter>
<managed-bean>
    <managed-bean-name>countryBean</managed-bean-name>
    <managed-bean-class>Test.CountryBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

CountryBean:

@Named("countryBean")
@SessionScoped
public class CountryBean implements Serializable {
    private EntityCountry selectedCountry;

    public EntityCountry getSelectedCountry() { return selectedCountry; }
    public void setSelectedCountry(EntityCountry newValue) { selectedCountry = newValue; }
}

And error:

PrettyFaces: Exception occurred while processing <country:#{countryBean.selectedCountry}> for URL </country/turkiye>
- Stack Trace
com.ocpsoft.pretty.PrettyException: PrettyFaces: Exception occurred while processing <country:#{countryBean.selectedCountry}> for URL 

</country/turkiye>
    at com.ocpsoft.pretty.faces.beans.ParameterInjector.injectPathParams(ParameterInjector.java:96)
    at com.ocpsoft.pretty.faces.beans.ParameterInjector.injectParameters(ParameterInjector.java:54)
    at com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:98)
    at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)
    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)
    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert turkiye of type class 

java.lang.String to class Test.EntityCountry
    at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:68)
    at org.jboss.weld.util.el.ForwardingExpressionFactory.coerceToType(ForwardingExpressionFactory.java:37)
    at com.ocpsoft.pretty.faces.util.FacesElUtils.setValue(FacesElUtils.java:86)
    at com.ocpsoft.pretty.faces.beans.ParameterInjector.injectPathParams(ParameterInjector.java:90)
    ... 46 more
Caused by: java.lang.IllegalArgumentException: Cannot convert turkiye of type class java.lang.String to 

class Test.EntityCountry
    at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:397)
    at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:66)
    ... 49 more
  • 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-28T01:47:29+00:00Added an answer on May 28, 2026 at 1:47 am

    It looks like you are using both PrettyFaces injection and ViewParams. If you are using ViewParams, you should use named parameters instead of parameter injection from PrettyFaces, like this:

    <url-mapping id="country">
        <pattern value="/country/#{country}" />
        <view-id value="/faces/countries/country.xhtml" />
    </url-mapping>
    

    Then you can let JSF do the work of converting the value as you have asked it to do so in .

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

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.