0

Long story short, I am experimenting on migrating to MyFaces on an application I am working on, when I noticed that the ViewState was over 18MB in size for a single page. I suspect this is because I have over 10 forms on this page, which is necessary because the page has over 10 ajaxified PrimeFaces dialogs and Ajax dialogs require their own internal form. It seems like the ViewState grows exponentially with each form. I read that MyFaces is far superior in efficiency with regards to ViewState so I am attempting to prototype my application to profile the results.

I notice a particular use case that was never a problem with Mojarra:

  • I have a PrimeFaces data table
  • Click an Edit button on a row
  • The selected row is updated to the model
  • I render the Edit Dialog's form to display the managed bean value of the selected row
  • The Edit button oncomplete attribute executes a script that displays the dialog.
  • Normal LOB data entry form where user Submits form
  • Persist to DB
  • Ajax render the data table with the new values for that record

The issue with MyFaces seems to be that it is more picky with the EL expressions by throwing a NullPointerException on the data table selected value if it happens to be null. This never occurred (for right or wrong) with Mojarra. Eg.

<h:form>
<p:dataTable var="bla" selection="#{managedBean.selectedValue}" ...>
  <p:column header="Options">
    <p:commandButton ajax="true" value="Edit" process="@this" update=":editDialogForm"
      oncomplete="editDialogWidget.show()" />
  </p:column>
    ...
</p:dataTable>
</h:form>

....

<p:dialog widgetVar="editDialogWidget" header="Edit stuff" ...>
  <h:form id="editDialogForm">
    <h:inputText value="#{managedBean.selectedValue.someHibernateProperty}" />
    ...
  </h:form>
</p:dialog>

You can clearly see where this would result in an NPE, but I was wondering if there is a context parameter that can be used in MyFaces so that it will behave like Mojarra in this respect with EL expressions? If not then is this a bug with Mojarra to where this should have never worked at all?

maple_shaft
  • 10,435
  • 6
  • 46
  • 74
  • Can you post stack trace? – partlov Mar 01 '13 at 20:36
  • @partlov using `process="@this"` in `` leads to the NPE since you send nothing to the server to process. – Luiggi Mendoza Mar 01 '13 at 20:53
  • MyFaces ships with [tonnes of context params](http://myfaces.apache.org/core20/myfaces-impl/webconfig.html), but [VALIDATE_EMPTY_FIELDS](http://myfaces.apache.org/core20/myfaces-impl/webconfig.html#javax_faces_VALIDATE_EMPTY_FIELDS) seems interesting in your context – kolossus Mar 01 '13 at 21:34
  • @LuiggiMendoza Why didn't Mojarra throw this exception I wonder? – maple_shaft Mar 01 '13 at 23:51
  • It happened to me when developing on JSF 1.2, I guess the NPEs for cases like this were swallowed and the JSP page just didn't work. – Luiggi Mendoza Mar 01 '13 at 23:57
  • As far as I can remember there is no such parameter. The EL library is not the problem, but check which EL lib you are using and check you are using the latest version. Instead, I think the culprit is in the app. One possible option is use "rendered" attribute, so if the selected value is null the form can be hidden and excluded from jsf validation phase. – lu4242 Mar 08 '13 at 03:48

0 Answers0