You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Thomas Andraschko (Jira)" <de...@myfaces.apache.org> on 2021/01/26 14:52:00 UTC

[jira] [Commented] (MYFACES-4379) FacesConfigUnmarshallerImpl - navigation-rules, view-param parsing

    [ https://issues.apache.org/jira/browse/MYFACES-4379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17272138#comment-17272138 ] 

Thomas Andraschko commented on MYFACES-4379:
--------------------------------------------

i think its only 2.3-next and 4.0/master? onChild is new and not ported to 2.3/3.0.

can you check if your stuff is working on 2.3 but not 2.3-next? If yes, would be great if you can provide unit tests.

> 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: 3.0.0-RC1, 2.3-next-M3, 2.3-next-M4, 3.0.0
>            Reporter: Milan Siebenbürger
>            Priority: Major
>
> 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)