HD> Why should that be on ViewMap? That would mean the ViewMap has to be
HD> cleared of these component references before state is saved.
Good point. It should really be on the FacesContext attributes Map.
Here is more from the reporter.
>>>>> On Wed, 6 Jul 2011 10:53:46 +0200, Rainer Sinkwitz said:
RS> Hi Mr. Burns,
RS> Thanks for your mail. Actually what you describe is possible and I use it
RS> as part of my IMHO kludgy solution. The key issue are the AJAX expressions
RS> and it seems I can either access the view for unsaved values or work with
RS> a copy of my model and extra code for loading and saving the copy against
RS> the model. Right now I think I should first update myself to JSF 2.0
RS> before I continue with any further proposal for this.
RS> For your information here is what I do right now: I make the UIComponent
RS> available as EL expression through a Map implementation with a only get()
RS> coded like
RS> public Object get(Object key)
RS> UIViewRoot viewRoot = FacesContext.
RS> return viewRoot.findComponent(((String)
RS> So if I have that map in the session, then I can use an EL expressions
RS> ... and viewMap[...].value gives me the converted object since there is
RS> UIComponent.getValue()/setValue(). So I have already what you describe,
RS> and even as a JSF expression, but I still find this kludgy.
RS> Lets me again describe by basic setting: Most of our forms have a "View"
RS> and an "Edit" mode, so that concurrent editing can be prevented with
RS> global locks. The main issue is the "Cancel" functionality which instead
RS> of updating the model must revert the form to it. Since the model is an
RS> attached JPA entity, JSF phase 4 must be suppressed. I currently do this
RS> with 'immediate="true"' on the cancel button and an action method that
RS> replaces the entire view with an empty one, then calling RenderResponse()
RS> to skip to phase 6, which in turn rebuilds the view and reloads the values
RS> from the model.
RS> So far so good, but the complication begins when I do AJAX updates with
RS> JBoss RichFaces Ajax4Jsf updating some dependent fields from unsaved
RS> values. Here it is that I need to use the above expressions.
RS> An alternative solution would be to let the form work against a copy of
RS> the JPA entity. Then AJAX could update the copy instead and use normal
RS> expressions against the copy. But then I need to do all the field copying
RS> from JPA entity to the copy and back and then somebody adds a new field
RS> and misses the copy code. Not a nice solution either.
RS> Anyway, thanks for your response, with best regards, Rainer