405 views
# Findings on f:viewParam problems ## EL versions in use - Dataverse Glassfish v4.1 containes EL v3.0.1b03 - Fix for ["String madness"](http://balusc.omnifaces.org/2015/10/the-empty-string-madness.html) shipped with v3.0.1b05 - meaning: we are affected by the setting of `javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL` doing nothing, will be handed over as empty strings - how is this related to primitive types like `int`? - Payara 5.192 ships EL v3.0.1b11 ## Error 500 because page = 0 When accessing the startpage of Dataverse, `f:viewAction` should render things (read: my dataverses and datasets) from the default `SearchIncludeFragment.search()`. This fails, as `page=0`. This seems to be related to `f:viewParam` assigning `page` to `SearchIncludeFragment.page`. This is an empty parameter when not included in GET request (as the case when heading for the Dataverse start page). **TODO**: Test what happens when accessing the page with `?page=1`! *Result: compare accessing [this (with param)](http://ec2-34-207-192-222.compute-1.amazonaws.com:8080/dataverse.xhtml?page=1) and [this (w/o param)](http://ec2-34-207-192-222.compute-1.amazonaws.com:8080/dataverse.xhtml). Notice the ERROR 500 in the later case.* When this solves the problem (it does, see above), my suspicion is: - JSF 2.2 and EL 3.0 in Glassfish 4.1 did not convert the empty parameter to 0, but instead the kinda "default" value from the class variable assignment is used (=1). - Now on Payara 5, updated libs break things by respecting the rules (need to dig for those...), thus page=0. **TODO**: 1. Find out what are the rules. Did they change/bugfix? 1. Rules are in EL 3.0 spec: https://download.oracle.com/otn-pub/jcp/el-3_0-fr-eval-spec/EL3.0.FR.pdf 2. Looking at section 1.23.3, "Coerce A to Number type N", first two rules: > If A is null and N is not a primitive type, return null > If A is null or "", return 0. 3. Looks like the current EL lib (b11) is simply following the rules, while b03 in Glassfish 4.1 is not. 2. Consider (with 4.1 compat for now, which might be challenging) 1. using [OmniFaces `o:viewParam`](http://showcase.omnifaces.org/components/viewParam), and use `default="1"` 2. *or* do proper handling with logic in the backing bean 3. What about adding validators for all `f:viewParam`? Things should not break so easily. 4. Can we add tests?