Enrique Medina wrote:

Hi Richard,

I've been reading your post, but I think I'm missing something...

If you set immediate=false, then only two phases will be executed:

1) Restore view
2) Apply request values

so, as you correctly say, the model will not be updated, as the "Update Model" phase is not invoked.

But AFAIK one thing is the component and another is the model. I mean, the component must be always updated independently of the value for the immediate attribute, so I don't understand why you loose your component values between requests (maybe it's just a matter of scope, and not really the immediate attribute).

You are correct. In this situation, when the user clicks the command link they are forwarded to a different page so they can do a "quick add" on the drop-down and then send them back to the main page with the information from before they clicked the link repopulated in the form. That's why I need the model updated is because then on the form that gets redirected to I can easily have <x:saveState> elements for each of the model values I want to save while the user goes to a different page. Then when they go back to the main page the saved values get put back in the model and the page looks just like when they left it except that now there's a new item in the drop-down.

Rich

Just my 2 cents ;-)

2005/8/24, Richard Wallace <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:

    James Reynolds wrote:

    >Ooo! I know this one!
    >
    >I lean heavily on the Core JSF book by Geary & Horstmann, there
    is some
    >good info on this in the page life cycle in Chapter
    7.  Specifically,
    >the Immediate Components information on page 292.  As you
    mentioned, the
    >immediate attribute must be set to true for your components.  The
    >portion I tripped up on was adding "context.renderResponse ();"
    at the
    >end of my ValueChangeEvent code for the
    valueChangeListener.  Then, the
    >model maintained the previous state of my page without firing
    >validation.
    >
    >
    >
    The problem with that is that then the model doesn't get updated when
    the command link is clicked so on the page they get directed to can't
    preserve the model info cause it was never updated.  The situation I
    have in mind is something like:

    The user loads the page.  They enter some contact info.  They
    click on
    one of the command links.  The contact info shouldn't be validated but
    the model values should be udpated.  If you look at the lifecycle the
    validation occurs before updating the model values.  And immediate
    event
    handling gets handled before validation.  So, if I set the immediate
    attribute to true it will forward to the "quick add" page before
    validating the data or updating the model.  So <t:saveState> will be
    preserving old information, not the latest info the user entered.

    >JR
    >
    >-----Original Message-----
    >From: Richard Wallace [mailto:[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>]
    >Sent: Wednesday, August 24, 2005 10:14 AM
    >To: MyFaces Discussion
    >Subject: Bypassing validation while still preserving values
    >
    >Hey everyone,
    >
    >I've got a form that has a couple of optional command links on
    it.  They
    >are basically "quick add" buttons so a user can quickly add things to
    >drop downs if they aren't there.  When these "quick add" buttons are
    >clicked the user is sent to an add page, the user enters the new
    info
    >and is then redirected back to the original page where the new
    entry is
    >selected and all the other data is preserved from before they clicked
    >the "quick add" button.  The backing beans involved are request
    scoped
    >and the values filled in before clicking the "quick add" button are
    >preserved through the process using the <t:saveState> element.
    >
    >I'm trying to get the validation correct. I want all the form
    elements
    >to be required when the user clicks the submit button, but when
    they hit
    >
    >the "quick add" link the validation should be bypassed.   I
    thought of
    >doing this with the immediate attribute set to true on the "quick
    add"
    >command links but if I do that then any data the user entered on that
    >page load (contact info type stuff) is lost.  So I kind of need to
    >bypass the validation but still update the model values if one of
    the
    >command links are clicked, but have full validation done when the
    >command button is pressed.
    >
    >I was looking at the new OptionalValidation Framework but I'm not
    sure
    >exactly how to apply it in this case.  I mean, what I really want
    is to
    >have the validation type be none when command links are used and hard
    >otherwise.
    >
    >Any ideas?
    >
    >Thanks,
    >Rich
    >
    >
    >



Reply via email to