myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dennis hoersch (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3702) ui:repeat is caching its data model if error occurs
Date Tue, 12 Mar 2013 15:57:13 GMT

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

dennis hoersch commented on MYFACES-3702:
-----------------------------------------

Sorry, I wasn't able to find the named issues.

Is it discussed at spec level somewhere?

---

The question is about the following JavaDoc of UIData?

void encodeBegin(FacesContext context)
  In addition to the default behavior, ensure that any saved per-row state for our child input
components is discarded unless it is needed to rerender the current page with errors.

I understand that sentence as it is talking about the row state, not the data model. But I
am not so deeply into the implementation and don't know if there might be a dependency between
the both.

---

Mojarra is implementing that encodeBegin() with 

private void preEncode(FacesContext context) {
    setDataModel(null); // re-evaluate even with server-side state saving
    if (!keepSaved(context)) { // check if context has errors
        getStateHelper().remove(PropertyKeys.saved); // usage of 'saved' looks like '_rowStates'
in MyFaces
    }
}

                
> ui:repeat is caching its data model if error occurs 
> ----------------------------------------------------
>
>                 Key: MYFACES-3702
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3702
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.10
>            Reporter: dennis hoersch
>
> ui:repeat caches its data model. Usually it it is cleared before rendering. But not if
there are any errors in faces context. 
> Why is it not cleared then?
> That causes a problem in the following scenario:
> We have an ui:repeat that iterating over a list of more detailed error messages of an
object on the page. This list is empty in the start of an request. While invoking an action
on the page error messages are added to the faces context to be shown on the page. Additionally
some more detailed information is stored to be shown directly with that object.
> But they won't appear because the empty list is cached in the ui:repeat's data model.
> I could reproduce it with the following more general example: The first button creates
an info message which will be shown by the ui:repeat. The second button creates an error message
and nothing is rendered through the ui:repeat.
> Testpage.xhtml
> <his:form id="testForm">
>   <h:commandButton value="Create info message" action="#{testController.createInfoMessage()}"
/>
>   <h:commandButton value="Create error message" action="#{testController.createErrorMessage()}"
/>
>   <br/>
>   UI:Repeat:
>   <ui:repeat var="item" value="#{facesContext.getMessageList()}">
>     FacesMessage #{item.severity} // #{item.summary}
>   </ui:repreat>|<br/>
>   Has Messages: #{not empty facesContext.getMessageList()}|
> </his:form>
> TestController
> public void createErrorMessage() {
>   MessageUtils.addMessage(FacesMessage.SEVERITY_ERROR, "Oh no, an error!", new Object[]
{});
> }
> public void createInfoMessage() {
>   MessageUtils.addMessage(FacesMessage.SEVERITY_INFO, "Just an information.", new Object[]
{});
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message