Invalid number path params when redirecting from non-JSF application Java code

Splash Forums PrettyFaces Users Invalid number path params when redirecting from non-JSF application Java code

This topic contains 0 replies, has 1 voice, and was last updated by  clemmonsm 10 years, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #18055

    clemmonsm
    Participant

    Hello,

    As the topic suggests, I am having trouble redirecting via Java using path parameters. The use case is: the user selects a city from a drop down which fires the vcMetroAreaRedirect ValueChangeEvent, where I wish to redirect the user to a city page. For pattern values that do not include a path parameter, the redirect works as expected (ex: pattern value=”/new-homes/new-york/”). However, for pattern values that do include a parameter (ex: “/new-homes/#{siteTasks.city}/”), I receive the following error (full stack below):

    com.ocpsoft.pretty.PrettyException: Invalid number of path parameters supplied for pattern “/new-homes/#{siteTasks.city}/”, expected <1>, but got <0>

    I am not certain if the issue centers around how I populate the params object that is passed to the PrettyURLBuilder or if it is a lifecycle related issue. The bean “siteTasks” is managed and city is a valid managed property. I am using JSF1.2, ADF 11.1.1.5 & PrettyFaces 3.3.0. Any help that can be provided would be appreciated. Thanks.

    Below you can find my config, code and stack trace:

    <url-mapping id=”city”>

    <pattern value=”/new-homes/#{siteTasks.city}/” />

    <view-id value=”/faces/pages/city.jspx” />

    </url-mapping>

    public void vcMetroAreaRedirect(ValueChangeEvent valueChangeEvent) {

    try {

    // Get the select one choice component

    RichSelectOneChoice selectedCity = (RichSelectOneChoice)valueChangeEvent.getSource();

    // Get the value string

    String selectedCityValue = (String)selectedCity.getValue();

    // put city value in request map – produces error: com.ocpsoft.pretty.PrettyException: Invalid number of path parameters supplied for pattern

    // First add value to request map

    //FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(“city”, selectedCityValue);

    // put city value into managed bean – produces error: com.ocpsoft.pretty.PrettyException: Invalid number of path parameters supplied for pattern

    //siteTasks st = (siteTasks) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(“siteTasks”);

    //// set selected value

    //if(st != null)

    // st.setCity(selectedCityValue);

    // Begin PrettyFaces redirect

    HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();

    HttpServletResponse response = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();

    PrettyContext context = PrettyContext.getCurrentInstance(request);

    // set PrettyFaces url-mapping id

    UrlMapping mapping = context.getConfig().getMappingById(selectedCityValue);

    // set city param

    String[] paramArray;

    paramArray = new String[1];

    paramArray[0] = selectedCityValue;

    Map<String, String[]> params = new TreeMap<String, String[]>();

    params.put(“city”, paramArray);

    PrettyURLBuilder builder = new PrettyURLBuilder();

    String targetURL = context.getContextPath() + builder.build(mapping, true, params);

    targetURL = response.encodeRedirectURL(targetURL);

    response.sendRedirect(targetURL);

    FacesContext.getCurrentInstance().responseComplete();

    } catch (IOException e) {

    e.printStackTrace(); // Can’t redirect

    } catch (Exception e) {

    e.printStackTrace();

    }

    }

    ERROR

    com.ocpsoft.pretty.PrettyException: Invalid number of path parameters supplied for pattern: /new-homes/#{siteTasks.city}/, expected <1>, but got <0>

    at com.ocpsoft.pretty.faces.url.URLPatternParser.getMappedURL(URLPatternParser.java:259)

    at com.ocpsoft.pretty.faces.util.PrettyURLBuilder.build(PrettyURLBuilder.java:262)

    at com.ocpsoft.pretty.faces.util.PrettyURLBuilder.build(PrettyURLBuilder.java:93)

    at bean.beanMetroArea.vcMetroAreaRedirect(beanMetroArea.java:107)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.sun.el.parser.AstValue.invoke(Unknown Source)

    at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)

    at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)

    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1256)

    at org.apache.myfaces.trinidad.component.UIXEditableValue.broadcast(UIXEditableValue.java:214)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:902)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:357)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)

    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)

    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)

    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)

    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)

    at java.security.AccessController.doPrivileged(Native Method)

    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)

    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)

    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)

    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)

    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)

    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)

    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)

    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)

    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

Viewing 1 post (of 1 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.