On second read I think I understand better. Looks like you have a
multi step process where you first do an expensive operation and then
on the second post to the same form you don't want to perform the
expensive operation. Almost like a wizard? In this case you might want
to think of moving to a another page for confirming the calculated
value?

But Click will have to construct the Form again to handle the submit
button click. You could also put a conditional around the form
creation eg. depending on wheather P is present and instead use the
page onPost method for handling the final post request.

Bob

On Fri, Apr 29, 2011 at 12:43 PM, Bob Schellink <[email protected]> wrote:
> I dont understand the problem then. Yes the form needs to be
> constructed again because Click need to process the submit button on
> the second request to invoke onSubmit. Also you might want to retrieve
> the value from a field in your Page. If the form and fields are not
> constructed, how will you retrieve the value? You will need to parse
> it directly from the request.
>
> You could always place an if-then-else to conditionally build the form
> or even POST your form to another page that doesn't contain the form.
> But I wouldn't recommend it.
>
> What is your concern with the fact that the form is created again?
>
> Bob
>
> On Fri, Apr 29, 2011 at 12:24 PM, Haim Schindler
> <[email protected]> wrote:
>> on the first request to:
>>
>>       www.mysite.com/clickPage?p=100
>>
>> the page was loaded and then:
>>
>> 1. based on "p=100" I do consuming calculation to calculate
>> "calculatedValue"
>> 2. now, I create the form, having "calculatedValue" as HiddenField.  (I dont
>> need the state "p" anymore for next steps)
>>
>> When submitting the form,  page is called again (for second time), but now,
>> the value of "p" is not relevant anymore (it could also be many "p"'s like:
>> "p1", "p2", ... , "p100").
>> I want to handle the "post" request, and for that I need only
>> "calculatedValue" I dont care about "p" now.
>> But because the way Click works, I have to construct the FORM again so
>> "onSubmit" will be executed.  why should I ?  I am not going to render the
>> form again, I just want to process the "onSubmit" call and then decide to
>> redirect to somewhere else. (in other words, I dont need the data the I
>> needed before to construct the form)
>>
>>
>>
>> On Fri, Apr 29, 2011 at 12:45 PM, Bob Schellink <[email protected]> wrote:
>>>
>>> This is fundamental to stateless, share nothing architectures. Each
>>> request needs all the information in order to satisfy the action. In
>>> your case you need p otherwise you cannot construct the form. There
>>> are geneally two options:
>>> - store P in the session
>>> - store P in a hiddenField and bind it's value explicitly if you need
>>> it before the onProcess event eg. during onInit:
>>>  ClickUtils.bind(pField);
>>>  pField.getValue();
>>>
>>> regards
>>>
>>> Bob
>>>
>>> On Fri, Apr 29, 2011 at 11:08 AM, Haim Schindler
>>> <[email protected]> wrote:
>>> > Hello,
>>> >
>>> > I am not sure what is the right way to use forms.
>>> > Sometimes its a problem when the form has to be constructed again after
>>> > submit and before the callback is called.
>>> >
>>> > Example:
>>> >
>>> > in url I type:
>>> >
>>> >      www.mysite.com/clickPage?p=100
>>> >
>>> > then in the click page I create a form.
>>> > based on the url parameter "p=100" in the form creation I do:
>>> >    ...
>>> >    Integer calculatedNumber = dbService.loadData(p);
>>> >    form.add(new HiddenField("calculatedNumber", calculatedNumber));
>>> >   ...
>>> >
>>> > I dont keep the "p" as a HIDDEN field in the form since I dont need it
>>> > anymore. all I care about now, is "calculatedNumber"
>>> >
>>> > the user clicked "SUBMIT"
>>> >
>>> > now, the calls should go to "onSubmit"
>>> > but before that, the form needs to be recreated, and it needs "p" to do
>>> > so.
>>> > but "p" is not there anymore and then I get exception
>>> >
>>> > Am I missing something ?
>>> >
>>> > Thank you
>>> > Haim Schindler
>>> >
>>
>>
>

Reply via email to