You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Entropy <bl...@gmail.com> on 2013/02/11 21:25:33 UTC

AjaxButton and a HiddenField

I have a javascript component that updates a HiddenField.  Then I want to
submit to the server via an AjaxButton.  It all works fine until I try to
get the value of the hiddenField which evidently did NOT hitch a ride on the
Ajax request.  How do I get the hiddenfield to join the ajax request?

Thanks.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton and a HiddenField

Posted by Entropy <bl...@gmail.com>.
That is just the piece of the machine I was having an issue with.  The
hidden is really just a repository for tracking javascript interaction
with a custom javascript component.  I am wrapping that component in a
Wicket panel for re-use, and the ajaxbutton is a collective event on
the selected rows.

So I'm not just using the hidden to persist some server side values,
but rather as a mechanism to get client side interaction to the server
from a component that doesn't exactly map to any of the basic wicket
components.

So as the user does things I am catching events and recording in that
hidden, and thus it can be submitted as simple data when the button is
pressed.

Brian Mulholland


On Tue, Feb 12, 2013 at 12:16 PM, Paul Bors [via Apache Wicket]
<ml...@n4.nabble.com> wrote:
> If you're working with Wicket, you should probably use Models and not set
> its value via JavaScript unless of course that's your business use-case.
>
> Mixing JavaScript, Ajax and a Wicket component seems a bit too elaborated
> for something simple such as persisting state via a hidden form field.
>
> Btw, are you sure you need the hidden field? Can’t you use compound models
> to hold on to the state you need at the panel or page level?
> Anyhow, I'll let you to it.. :)
>
> ~ Thank you,
>     Paul Bors
>
> On Tue, Feb 12, 2013 at 10:02 AM, Entropy <[hidden email]> wrote:
>
>> Well, I solved it and it turns out that it wasn't a Wicket issue.  I was
>> setting the value in javascript, but I eventually realized that I was
>> setting it to the wrong object...so when i stepped and saw the value, I
>> assumed that it was in the hidden, but I was wrong.
>>
>> Ooops.  Thanks for your effort anyway gang.
>>
>>
>>
>> --
>> View this message in context:
>>
>> http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656277.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
> ~ Thank you,
>     Paul@Bors.ws
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656280.html
> To unsubscribe from AjaxButton and a HiddenField, click here.
> NAML




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656282.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton and a HiddenField

Posted by Paul Bors <pa...@bors.ws>.
If you're working with Wicket, you should probably use Models and not set
its value via JavaScript unless of course that's your business use-case.

Mixing JavaScript, Ajax and a Wicket component seems a bit too elaborated
for something simple such as persisting state via a hidden form field.

Btw, are you sure you need the hidden field? Can’t you use compound models
to hold on to the state you need at the panel or page level?
Anyhow, I'll let you to it.. :)

~ Thank you,
    Paul Bors

On Tue, Feb 12, 2013 at 10:02 AM, Entropy <bl...@gmail.com> wrote:

> Well, I solved it and it turns out that it wasn't a Wicket issue.  I was
> setting the value in javascript, but I eventually realized that I was
> setting it to the wrong object...so when i stepped and saw the value, I
> assumed that it was in the hidden, but I was wrong.
>
> Ooops.  Thanks for your effort anyway gang.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656277.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: AjaxButton and a HiddenField

Posted by Entropy <bl...@gmail.com>.
Well, I solved it and it turns out that it wasn't a Wicket issue.  I was
setting the value in javascript, but I eventually realized that I was
setting it to the wrong object...so when i stepped and saw the value, I
assumed that it was in the hidden, but I was wrong.

Ooops.  Thanks for your effort anyway gang.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656277.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton and a HiddenField

Posted by Martin Grigorov <mg...@apache.org>.
The code looks OK.
It seems the JavaScript doesn't serialize the hidden field and doesn't
include it in the submit data.

If you are able to reproduce this with Wicket 6 please file a ticket with a
quickstart. Unfortunately 1.4.7 is too old and is not supported by us
anymore.


On Tue, Feb 12, 2013 at 3:34 PM, Entropy <bl...@gmail.com> wrote:

> Yes, I have a form (wicket Form) around both the hidden and the ajaxbutton.
> We appear to be on 1.4.7.
>
> The java for the ajaxbutton looks like so:
>
> form.add(new AjaxButton("gridtestbutton") {
>   protected void onSubmit(AjaxRequestTarget arg0, Form<?> arg1) {
>     //some code that gets the HiddenField, parses it, and reacts...but the
> value is always empty.
>   }
> });
>
> The code that adds the hidden looks like:
>
> add(new HiddenField("rowsSelected", new Model("")));
>
> That add adds to a custom panel that holds the hidden, and is in turn is
> added to the form.
>
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656275.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: AjaxButton and a HiddenField

Posted by Entropy <bl...@gmail.com>.
Yes, I have a form (wicket Form) around both the hidden and the ajaxbutton. 
We appear to be on 1.4.7.

The java for the ajaxbutton looks like so:

form.add(new AjaxButton("gridtestbutton") {
  protected void onSubmit(AjaxRequestTarget arg0, Form<?> arg1) {
    //some code that gets the HiddenField, parses it, and reacts...but the
value is always empty.
  }
});

The code that adds the hidden looks like:

add(new HiddenField("rowsSelected", new Model("")));

That add adds to a custom panel that holds the hidden, and is in turn is
added to the form.





--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656275.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton and a HiddenField

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

AjaxButton just submits a form using XmlHttpRequest, or IFrame when there
is file input in the form.
Is the hidden input field part of that form ?

Which version of Wicket do you use ?
Can you show us the related Java and HTML snippets ?


On Tue, Feb 12, 2013 at 3:15 PM, Entropy <bl...@gmail.com> wrote:

> Okay, so the only AjaxRequestTarget I am aware of is the one passed to me
> in
> the onSubmit.  This being after the ajax has submitted. I thought that was
> for OUTPUT, ie what controls will the ajax update when it returns from the
> ajax event.
>
>  I am not trying to update the hiddenfield in the ajaxbutton, but rather
> using what is there are input into the code that will run during my
> onSubmit.  I can't seem to find where I would register the hiddenfield with
> the ajaxbutton BEFORE the ajax event.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656270.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: AjaxButton and a HiddenField

Posted by Entropy <bl...@gmail.com>.
To elaborate, I already made the Hidden a HiddenField, it just doesn't get
updated before the onSubmit().  The Hidden's value is set via javascript on
the client, and I want that value as INPUT into the code tha truns in
onSubmit.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656274.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton and a HiddenField

Posted by Entropy <bl...@gmail.com>.
Okay, so the only AjaxRequestTarget I am aware of is the one passed to me in
the onSubmit.  This being after the ajax has submitted. I thought that was
for OUTPUT, ie what controls will the ajax update when it returns from the
ajax event.

 I am not trying to update the hiddenfield in the ajaxbutton, but rather
using what is there are input into the code that will run during my
onSubmit.  I can't seem to find where I would register the hiddenfield with
the ajaxbutton BEFORE the ajax event.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246p4656270.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton and a HiddenField

Posted by Paul Bors <pa...@bors.ws>.
You turn your hidden field into a Wicket FormComponent and then add it to
your button's ajax request target :)

Just because is hidden, it doesn't have to be treated any different. But
don't confuse a hidden field with a Wicket visible field.

~ Thak you,
   Paul Bors

On Mon, Feb 11, 2013 at 3:25 PM, Entropy <bl...@gmail.com> wrote:

> I have a javascript component that updates a HiddenField.  Then I want to
> submit to the server via an AjaxButton.  It all works fine until I try to
> get the value of the hiddenField which evidently did NOT hitch a ride on
> the
> Ajax request.  How do I get the hiddenfield to join the ajax request?
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxButton-and-a-HiddenField-tp4656246.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>