[ https://issues.apache.org/jira/browse/MYFACES-4379?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Andraschko resolved MYFACES-4379. ---------------------------------------- Resolution: Fixed > FacesConfigUnmarshallerImpl - navigation-rules, view-param parsing > ------------------------------------------------------------------ > > Key: MYFACES-4379 > URL: https://issues.apache.org/jira/browse/MYFACES-4379 > Project: MyFaces Core > Issue Type: Bug > Components: General > Affects Versions: 2.3-next-M3, 2.3-next-M4, 4.0.0-RC1 > Reporter: Milan Siebenbürger > Assignee: Thomas Andraschko > Priority: Major > Fix For: 2.3-next-M5, 4.0.0-RC1 > > Attachments: image-2021-01-26-18-01-58-622.png, > image-2021-01-26-18-02-38-773.png > > > Hello, > could you please check FacesConfigUnmarshallerImpl, we discovered some issues > in navigation rules parsing, especially view-param / redirect-param. Is there > is something wrong on our side? > The specific configuration of navigation rules xml looks like this > {code:java} > <redirect> > <view-param> > <name>cid</name> > <value></value> > </view-param> > </redirect> > {code} > Issue 1. - viewParams are not handled correctly: > {code:java} > onChild("view-param", n, (cn) -> { > ViewParamImpl vp = new ViewParamImpl(); > r.addViewParam(vp); > onChild("name", cn, (ccn) -> { > vp.setName(ccn.getTextContent()); }); > onChild("value", cn, (ccn) -> { > vp.setValue(ccn.getTextContent()); }); > }); > {code} > If I understand it correctly, empty ViewParamImpl si created, added to r > (RedirectImpl), and after that it is filled with xml values. > In RedirectImpl, method addViewParam, is ViewParam attribute transformed to > key/value combination and added to local HashMap. Because it is empty (yet), > empty key is created in local HashMap, and no values are filled. > {code:java} > public void addViewParam(ViewParamImpl viewParam) > { > if (viewParams == null) > { > viewParams = new HashMap<>(3, 1f); > } > List<String> params = viewParams.computeIfAbsent(viewParam.getName(), k > -> new ArrayList<>(3)); > params.add(viewParam.getValue()); > }{code} > Rest of implementation is irrelevant. > What do you think about changing order of command like that -> > {code:java} > onChild("view-param", n, (cn) -> { > ViewParamImpl vp = new ViewParamImpl(); > > onChild("name", cn, (ccn) -> { > vp.setName(ccn.getTextContent()); }); > onChild("value", cn, (ccn) -> { > vp.setValue(ccn.getTextContent()); }); > r.addViewParam(vp); // moved down > }); > {code} > same, with redirect-param .. and maybe others .. > > Issue 2. - empty value in view-param parameter > As is seen in example above, we need to pass empty value to view-param. But > method getTextContent returns null as a value. > After that, NPE is throwed: > {noformat} > java.lang.NullPointerException: null > at java.net.URLEncoder.encode(URLEncoder.java:204) > at > org.apache.myfaces.context.servlet.ServletExternalContextImpl.encodeURL(ServletExternalContextImpl.java:990) > at > org.apache.myfaces.context.servlet.ServletExternalContextImpl.encodeRedirectURL(ServletExternalContextImpl.java:455) > at > javax.faces.context.ExternalContextWrapper.encodeRedirectURL(ExternalContextWrapper.java:101) > at > javax.faces.context.ExternalContextWrapper.encodeRedirectURL(ExternalContextWrapper.java:101) > at > org.apache.myfaces.application.ViewHandlerImpl.getRedirectURL(ViewHandlerImpl.java:175) > at > javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:142) > at > org.apache.webbeans.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:89) > at > javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:142){noformat} > Is it possible to pass empty value somehow? > Thanks > Milan Siebenbürger > > > -- This message was sent by Atlassian Jira (v8.3.4#803005)