Andrew,

all suggested solutions are nearly the same. 
I would have to reset the components manually which is from my point of
view impossible and not manageable.

I will add this issue to the ajax4jsf forum in order to get a statement
from their point of view.

OT:
I am just curious which ajax framework do you use/recommend?
Did you ever port an app to another ajax framework?
I realized also some problems with ajax4jsf but all of them could be
solved with workarounds until this one.

Michael


-----Original Message-----
From: Andrew Robinson [mailto:[EMAIL PROTECTED] 
Sent: Dienstag, 25. September 2007 17:11
To: MyFaces Discussion
Subject: Re: [jira] Commented: (MYFACES-1714) submitted (or local)
values are not erasable after conversion or validation error

Michael,

The problem that you are having isn't a JSF problem, and really isn't
a problem or bug at all. You have chosen to use A4J region and
ajaxSingle=true. By doing so, you have chosen to "break" the JSF
lifecycle. By bypassing the normal decode and rendering of the JSF
components (especially with the ajaxSingle), you have prevented the
normal behavior of JSF of the components. This is one large reason I
have stopped using A4J, it does a lot of things that look really nice
at first until you realize that it is not in a "JSF compatible way"
necessarily.

Now, more than once people have given you a workable solution, but you
refuse to use component binding, so I'd like to propose that you use a
new custom component to do what you want.

Here is the pseudo code for this component:

public class UIResetSubmittedValue
extends UIComponentBase {

// JSF property "for"

encode end () {
f = get for value ()
c = this.findComponent( f )

if (c != null and c is an editable value holder) {
  set c local value to null
  set c submitted value to null
  set c has local value to null
}
}

save state () {
// save the "for" property
}

restore state () {
// restore the "for" property
}
}

Usage:

<a4j:region>
<t:inputText value="#{valueThatChanges}" id="mytext">
<a4j:support event="onblur" ajaxSingle="true" />
</t:inputText>
<my:resetSubmittedValue for="mytext" />
</a4j:region>

Then all you need to do, is every time you re-render myText, make sure
you re-render the resetSubmittedValue component (possibly use the
parent component as your re-render target).

Hope this helps.

-Andrew

On 9/25/07, Andrew Robinson (JIRA) <[EMAIL PROTECTED]> wrote:
>
>     [
https://issues.apache.org/jira/browse/MYFACES-1714?page=com.atlassian.ji
ra.plugin.system.issuetabpanels:comment-tabpanel#action_12530110 ]
>
> Andrew Robinson commented on MYFACES-1714:
> ------------------------------------------
>
> We should take this back to the mailing list and out of JIRA
>
> FYI, this issue has had some lengthy discussion on the list already,
by you. I don't think that there is much more to say
>
>
http://www.nabble.com/how-to-reset-submitted-values-caused-by-validation
-errors---tf3995414.html#a11362553
>
> > submitted (or local) values are not erasable after conversion or
validation error
> >
------------------------------------------------------------------------
---------
> >
> >                 Key: MYFACES-1714
> >                 URL:
https://issues.apache.org/jira/browse/MYFACES-1714
> >             Project: MyFaces Core
> >          Issue Type: Bug
> >    Affects Versions: 1.1.5
> >         Environment: tomcat 5.5.23
> > myfaces 1.1.5
> > tomahawk 1.1.5
> > ajax4jsf 1.1.1
> >            Reporter: Michael Heinen
> >            Priority: Critical
> >         Attachments: validation.war
> >
> >
> > There is a serious conversion/validation problem with JSF in
combination with ajax..
> > From my point of view this is a major show stopper for jsf
applications in combination with ajax.
> > Therefore I created a simple demo application and attach it to this
issue.
> > My form contains a few input fields for Strings, dates and a number.
If an invalid format is entered then the submitted value is not erased
and the page is rerendered with the entered value.
> > This is working fine so far.
> >
> > The error occurs now if I click then another ajax command that
forces a refresh of the invalid fields via ajax.
> > I use an a4j:commandButton with ajaxSingle=true and surrounded this
button by an a4j:region in order to process no input fields on
serverside.
> > The values that are bound via valueBinding to the inputFields are
set to null or reinitialized in the invoked ActionListener.
> > But the old invalid data from the previous request is rerendered on
the page.
> >
> > This happens because the submitted values of the invalid inputFields
are not null but still contain the old invalid data.
> > Therefore the valueBinding is not evaluated in the getter.
> >
> > I can't set the submitted value to null in the converter because
invalid values should be rerendered in case that a normal processing
button (not cancel button) is clicked.
> > Pls have a look at the demo application:
> > Call ... faces/test.jsp
> > 1) Enter some data
> >    (e.g name="twotest", startDate="01/01/70", endDate="01/01/70"
message="hello" count=55)
> >    and click save
> >    Result: Everything works fine.The new object is rendered in the
list
> > 2) Enter invalid data
> >    (e.g. number=doh)
> >    and click save
> >    Result: conversion error "Count:": value is no valid number
(don't know the correct english message)
> > 3) Click create new
> >    Result: Field count does still contain the old value doh
> >
> > 4) Click Edit
> >    Result: Field count does still contain the old value doh
> >    The other fields are correctly initialized
> >
> > My first approach was to except submittedValue from stateSaving but
this did not solve the problem..
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>

Reply via email to