Thank you, Igor.  That did work; adding the ListChoice as a target component
does get the AJAX to update properly.  I am grateful for your help.

I had been trying to do it without AJAX, for the sake of browsers that don't
allow JavaScript.  Now, let me understand why it didn't work without AJAX. 
I thought that since the page after the submit was a copy of the original
page, that we would do a round trip on submission.  I thought we'd hit the
constructor again and a trace shows we don't.  I had thought the new page
would load up whatever was in the models, and if I changed the model content
before the submit was over, the new data should show up.  Since it didn't,
does this mean that the new page uses what's in the HTML rather than what's
in the model?  Or does it mean that even in a non-AJAX page, only the
controls you add as onSubmit targets get updated with the model contents?


igor.vaynberg wrote:
> 
> it doesnt have an onclick() but it does have an onsubmit().
> 
> i suggest you take a look at how ajax examples work in our examples
> project. if you want to repaint some part of the screen when you press
> an ajax button you have to add that part to the ajax request target
> using target.addcomponent() - that is how you tell wicket what to
> repaint...
> 
> -igor
> 
> On Fri, Oct 3, 2008 at 5:52 AM, Shelah Horvitz
> <[EMAIL PROTECTED]> wrote:
>> Thank you, Igor, for getting back to me so quickly.  Actually, thank you
>> for answering at all.
>>
>> I thought of the onclick handler, but the AjaxFallbackButton doesn't have
>> an onClick() function.  It does have a getOnClickScript() which I can
>> override, but I believe the timing will be off.  I think it will fire
>> before the form is submitted.  Hold on, I think I get what you're saying:
>> write some JavaScript AJAX for the onclick script that will call whatever
>> routines I need to create the user and then update the ListChoice's
>> model.  I don't need to do anything with the onSubmit() overload.  Is
>> that what you're saying?  I will try it.  I think it's a good idea.
>>
>> An interesting aspect of this solution is that I don't think I even need
>> a form.  I think the validation of control inputs would happen after the
>> onclick handler returns.  I think this is a strictly roll-your-own
>> solution.
>>
>> Have I got it right?
>>
>> ________________________________________
>> From: Igor Vaynberg [EMAIL PROTECTED]
>> Sent: Thursday, October 02, 2008 4:42 PM
>> To: users@wicket.apache.org
>> Subject: Re: How to update ListChoice after form submission?
>>
>> inside the onclick of your ajaxfallbackbutton you have to add the
>> listchoice to the target so wicket rerenders it
>>
>> -igor
>>
>> On Thu, Oct 2, 2008 at 12:49 PM, Seven Corners <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> I have a page with a ListChoice of user names that is populated with a
>>> call
>>> to our server (loadUserNames()).  The page also contains a number of
>>> TextFields corresponding to the user's other attributes.  When you
>>> modify
>>> those text fields so the user name doesn't correspond to anything in the
>>> list, the Add AjaxFallbackButton enables.  Click this, and you make a
>>> call
>>> to the server which creates the new user.
>>>
>>> The new user does not show up in the ListChoice.  If you refresh the
>>> page,
>>> it does, so we know it's created, and we know that loadUserNames() will
>>> return the correct list if it were called and its values were used..  I
>>> want
>>> the new user name to show up in the ListChoice after submission, and I'd
>>> like to be able to set the selection in the ListChoice to the new user.
>>> I've tried giving the ListChoice a LoadableDetachableModel, I've tried
>>> giving it an ArrayList model with a call to loadUserNames() and
>>> setChoices()
>>> on the ListChoice after submission, I've tried a
>>> AjaxFormComponentUpdatingBehavior( "onsubmit" ), hoping this might fire
>>> after submission, I've tried using a call to
>>> getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.ONE_PASS_RENDER)
>>> in my application class's init() method, I've tried a ton of things and
>>> I
>>> can't figure this out.
>>>
>>> Any ideas?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-update-ListChoice-after-form-submission--tp19786374p19786374.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-update-ListChoice-after-form-submission--tp19786374p19816326.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to