Re: Session Timeout - detect last visited page and redirect accordingly

2010-05-03 Thread Tony Wu
Seems messy to have to carry that to every single URL. I was thinking about
redirecting to a Proxy page and having the logic there to redirect
elsewhere. The thing is I don't know what page I'm from once I'm at the
proxy. I suppose I can store the last visited page in a cookie, but I'd like
to avoid that route if possible.

On Mon, May 3, 2010 at 5:32 PM, Igor Vaynberg wrote:

> you can append the class name of the last visited page to every url by
> creating your own url coding strategy
>
> -igor
>
> On Mon, May 3, 2010 at 4:59 PM, Tony Wu  wrote:
> > I have an application where on session timeout, I want to redirect to
> > different pages based on what their last visited page was. Currently my
> app
> > only redirects to the same page all the time through
> > getApplicationSettings().setPageExpiredErrorPage(LoginPage.class). Is
> there
> > any way to capture the prior page and redirect them accordingly?
> >
> > Thanks,
> > Tony
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Session Timeout - detect last visited page and redirect accordingly

2010-05-03 Thread Tony Wu
I have an application where on session timeout, I want to redirect to
different pages based on what their last visited page was. Currently my app
only redirects to the same page all the time through
getApplicationSettings().setPageExpiredErrorPage(LoginPage.class). Is there
any way to capture the prior page and redirect them accordingly?

Thanks,
Tony


BookmarkablePageLink auto-generated "name" is no longer there

2010-04-01 Thread Tony Wu
I've been using BookmarkablePageLink for my site navigation. A month or so
ago I remember each BookmarkablePageLink would autogenerate a
name="{wicket:id}" in the HTML, and I was using this to hook into functional
testing as the locator, etc.

For example:
.html


.java
add(new BookmarkablePageLink("enrollNowLink", EnrollmentPage.class));

This USED to output:


But now outputs:


What would cause the auto generated name={wicket:id} to drop off? It seems
like it's random too, as some links still have the autogenerated name and
some don't. Any insights?

Thanks,
Tony


FormTester - submitting AjaxFallbackButtons!

2010-03-12 Thread Tony Wu
I have an AjaxFallbackButton which onSubmit does some validation and then
sets a container visible. When I do:

FormTester.submit("path.to.ajaxFallbackButton");

It seems to work fine (no errors in the console or junit), but the button
doesn't actually get onSubmitted (assert container visible fails). The form
itself doesn't even process (I @Override form's process function to print
something but it never went there). If I change the AjaxFallbackButton to a
regular Button, it works fine.

Igor over at the IRC channels suggested to use tester.executeAjaxEvent with
"onclick" - but that doesn't work either. So opening up the question to the
list... any ideas guys?

Thanks,
Tony


Re: FormTester - submitting more than once

2010-03-12 Thread Tony Wu
Any way to do it without running Selenium?

On Mar 12, 2010, at 6:01 AM, Kent Tong wrote:

> 
> 
> Tony Wu-5 wrote:
>> 
>> However, I can't
>> do this unit test in Wicket because a FormTester can only submit once. I
>> can't resetup the FormTester data because the 2nd submit button (checkout)
>> requires a state that the 1st submit button sets.
>> 
> 
> Yes, you can make it work if you use http://wicketpagetest.sourceforge.net/
> 
> -
> --
> Kent Tong
> Better way to unit test Wicket pages (http://wicketpagetest.sourceforge.net)
> Books on CXF, Axis2, Wicket, JSF (http://agileskills2.org)
> -- 
> View this message in context: 
> http://old.nabble.com/FormTester---submitting-more-than-once-tp27873217p27874748.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 


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



FormTester - submitting more than once

2010-03-11 Thread Tony Wu
I'm trying to write a unit test for a form. I have a form with 2 submit
buttons. The 1st submit button is an AjaxSubmitButton which allows the user
to enter a ID, that then shows all the products associated with that ID (it
requires validators to run which is why it's a submit button). The 2nd
submit button will validate the entire form and checkout. However, I can't
do this unit test in Wicket because a FormTester can only submit once. I
can't resetup the FormTester data because the 2nd submit button (checkout)
requires a state that the 1st submit button sets.

How can I make my unit test work?

Thanks,
Tony


FormComponentPanel's components onblur can't call validate?

2010-03-09 Thread Tony Wu
I have a FormComponentPanel which holds 3 dropdowns for month-day-year (it's
a birthday FormComponentPanel). I override convertInput on the
FormComponentPanel to return the age based on the 3 drop downs. I have an
age validator which makes sure they're over 18.

Now, this all works fine on form submit (convertInput gets called and it
runs the validator).

But when I try to do it dynamically by attaching a onchange
AjaxFormUpdatingBehavior event to the 3 drop downs to call
FormComponentPanel.validate() (@Override onUpdate, and only when all 3 drop
downs are selected of course), I know the onchange triggers (because it's
@Override onUpdate runs - had a system.out.println which runs), but the
validate() function doesn't run the age validator. It actually *never even
calls convertInput* on the FormComponentPanel. Any ideas?


Re: mountBookmarkablePage issue with panels

2010-03-09 Thread Tony Wu
Thanks, the new version does fix this issue.

On Tue, Mar 9, 2010 at 8:50 AM, vineet semwal wrote:

> are you on 1.4.6, if yes please upgrade to 1.4.7 and see if the problem
> disappears.
>
> On Tue, Mar 9, 2010 at 9:16 PM, Tony Wu  wrote:
>
> > I have a Signup page that's mounted using
> > mountBookmarkablePage("/section/signup", Signup.class). On that page I
> have
> > a panel which has a button that onclick, will basically redirect to
> itself -
> > it does setResponsePage(panel.getPage().getClass()). When the button is
> > clicked it redirects me to /section/section/signup instead of
> > /section/signup.
> >
> > I've isolated the issue in that it doesn't like the mount name. If I use
> > "/section-signup" as the URL name instead (without the frontslash) it
> works
> > perfectly. Is this a bug?
> >
> > Thanks,
> > Tony
>
>
>
>
> --
> regards,
> Vineet Semwal
>


mountBookmarkablePage issue with panels

2010-03-09 Thread Tony Wu
I have a Signup page that's mounted using 
mountBookmarkablePage("/section/signup", Signup.class). On that page I have a 
panel which has a button that onclick, will basically redirect to itself - it 
does setResponsePage(panel.getPage().getClass()). When the button is clicked it 
redirects me to /section/section/signup instead of /section/signup.

I've isolated the issue in that it doesn't like the mount name. If I use 
"/section-signup" as the URL name instead (without the frontslash) it works 
perfectly. Is this a bug?

Thanks,
Tony

Re: Getting a TextField's value without form submitting

2010-02-25 Thread Tony Wu
Any solution that doesn't require nested forms?

On Thu, Feb 25, 2010 at 5:33 PM, Igor Vaynberg wrote:

> easy. put each section into its own form, all inside the one big form.
> if a button of the inner form is pressed only that form is validated,
> while values for the entire form are preserved.
>
> there is a wiki page which explains how embedded forms work.
>
> -igor
>
> On Thu, Feb 25, 2010 at 4:30 PM, Tony Wu  wrote:
> > Thanks Igor, my use case was an attempt to solve a bigger problem. Let me
> > try to describe the main problem I am trying to solve:
> >
> > I have 1 big form with 3 distinct sections. Each section has an "update"
> > link which should run every FormComponent's validators for that section.
> The
> > trick is I can't use form submission because I don't want to validate the
> > other parts of the form, just that 1 section and provide error feedback
> if
> > necessary. The final button on the form is an actual submit, which will
> run
> > through every FormComponent's validators on the page. I thought about
> > splitting it up into 3 separate forms so each "update" link is actually a
> > submit, but the final button needs to validate every input in every
> section
> > - so that's why I'm using 1 form. I thought about nested forms as well,
> but
> > that isn't syntactically correct in HTML.
> >
> > The crux of the problem is I need to run validators for only specific
> > FormComponents without doing a form submit. Is there any way I can do
> that
> > with wicket?
> >
> > Thanks,
> > Tony
> >
> > On Thu, Feb 25, 2010 at 5:00 PM, Igor Vaynberg  >wrote:
> >
> >> links do not transfer form values to the serverside, so you need to
> >> use a bit of js to do it for you. not sure exactly what your usecase
> >> is (sounds strange), but here goes off the top of my head:
> >>
> >> abstract class myuberlink extends link {
> >>  private final textfield tf;
> >>  public myuberlink(string id, textfield tf) { super(id);this.tf=tf;
> >> tf.setoutputmarkupid(true);}
> >>  public void oncomponenttag(tag) {
> >>
> >>
>  
> tag.put("onclick","this.href=this.href+'&"+tf.getinputname()+"='+document.getElementById('"+tf.getmarkupid()+"').value;
> >> return true;"); }
> >>
> >>  public final void onclick() {
> >> onclick(getrequest().getattribute(tf.getinputname()); }
> >>
> >>  protected abstract void onclick(string value);
> >> }
> >>
> >> -igor
> >>
> >> On Thu, Feb 25, 2010 at 3:51 PM, Tony Wu  wrote:
> >> > Is there a way to get a TextField's value without submitting the form?
> >> For
> >> > example, if I have a TextField and a Link (not a submit Button), I
> want
> >> the
> >> > Link's onClick to System.out.println the TextField's value at that
> time.
> >> I
> >> > tried using TextField.getInput, getConvertedInput, no dice on both.
> >> >
> >> > I even tried adding a AjaxFormComponentUpdatingBehavior to the
> TextField
> >> for
> >> > "onchange", which does work to change the TextField's model whenever a
> >> user
> >> > types something, but it's getInput and getConvertedInput is always
> null
> >> when
> >> > I click the Link. Even if the AjaxFormComponentUpdatingBehavior's
> >> onUpdate I
> >> > do TextField.setConvertedInput(model's new value) explicity, both
> >> getInput
> >> > and getConvertedInput are both null.
> >> >
> >> > Any ideas?
> >> >
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Getting a TextField's value without form submitting

2010-02-25 Thread Tony Wu
Thanks Igor, my use case was an attempt to solve a bigger problem. Let me
try to describe the main problem I am trying to solve:

I have 1 big form with 3 distinct sections. Each section has an "update"
link which should run every FormComponent's validators for that section. The
trick is I can't use form submission because I don't want to validate the
other parts of the form, just that 1 section and provide error feedback if
necessary. The final button on the form is an actual submit, which will run
through every FormComponent's validators on the page. I thought about
splitting it up into 3 separate forms so each "update" link is actually a
submit, but the final button needs to validate every input in every section
- so that's why I'm using 1 form. I thought about nested forms as well, but
that isn't syntactically correct in HTML.

The crux of the problem is I need to run validators for only specific
FormComponents without doing a form submit. Is there any way I can do that
with wicket?

Thanks,
Tony

On Thu, Feb 25, 2010 at 5:00 PM, Igor Vaynberg wrote:

> links do not transfer form values to the serverside, so you need to
> use a bit of js to do it for you. not sure exactly what your usecase
> is (sounds strange), but here goes off the top of my head:
>
> abstract class myuberlink extends link {
>  private final textfield tf;
>  public myuberlink(string id, textfield tf) { super(id);this.tf=tf;
> tf.setoutputmarkupid(true);}
>  public void oncomponenttag(tag) {
>
>  
> tag.put("onclick","this.href=this.href+'&"+tf.getinputname()+"='+document.getElementById('"+tf.getmarkupid()+"').value;
> return true;"); }
>
>  public final void onclick() {
> onclick(getrequest().getattribute(tf.getinputname()); }
>
>  protected abstract void onclick(string value);
> }
>
> -igor
>
> On Thu, Feb 25, 2010 at 3:51 PM, Tony Wu  wrote:
> > Is there a way to get a TextField's value without submitting the form?
> For
> > example, if I have a TextField and a Link (not a submit Button), I want
> the
> > Link's onClick to System.out.println the TextField's value at that time.
> I
> > tried using TextField.getInput, getConvertedInput, no dice on both.
> >
> > I even tried adding a AjaxFormComponentUpdatingBehavior to the TextField
> for
> > "onchange", which does work to change the TextField's model whenever a
> user
> > types something, but it's getInput and getConvertedInput is always null
> when
> > I click the Link. Even if the AjaxFormComponentUpdatingBehavior's
> onUpdate I
> > do TextField.setConvertedInput(model's new value) explicity, both
> getInput
> > and getConvertedInput are both null.
> >
> > Any ideas?
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Getting a TextField's value without form submitting

2010-02-25 Thread Tony Wu
Is there a way to get a TextField's value without submitting the form? For
example, if I have a TextField and a Link (not a submit Button), I want the
Link's onClick to System.out.println the TextField's value at that time. I
tried using TextField.getInput, getConvertedInput, no dice on both.

I even tried adding a AjaxFormComponentUpdatingBehavior to the TextField for
"onchange", which does work to change the TextField's model whenever a user
types something, but it's getInput and getConvertedInput is always null when
I click the Link. Even if the AjaxFormComponentUpdatingBehavior's onUpdate I
do TextField.setConvertedInput(model's new value) explicity, both getInput
and getConvertedInput are both null.

Any ideas?


Scroll to Anchor on Form Submit

2010-02-12 Thread Tony Wu
Is there a way in Wicket for Button form onSubmit to refresh the page and
scroll to a particular anchor? For example if I have 3 separate forms with a
FeedbackPanel in each, if I click the submit button for the final form and
there's a validation error, when the page refreshes the error messages are
at the bottom. It's not apparent to the user anything happened unless they
manually scroll down. It would be great if there's a way to scroll to
href="#someanchor". I think there's a setAnchor function in wicket, but
that's only for Links. Is there anything that works for Buttons/Form
submission?


Hook Before Form Validation on a Button

2010-02-11 Thread Tony Wu
For form submission I can override onSubmit to do my own processing, but is
there anything I can override that happens BEFORE the form validation? I
need to for example, based on which Button they press, .setRequired(false)
on some components before the form processing kicks in.

I tried @Override validate() to temporarily do nothing, but the form
validation still kicks in. And validateValidators() is final so can't be
overwritten.

Any ideas?


removing validators

2010-02-09 Thread Tony Wu
In total I have 4 DropDownChoices:

I have a DropDownChoice which allows a user to select whether they are an
adult or minor. I have another FormComponentPanel with 3 DropDownChoices
representing their birthdate (year, month, day) with a setConvertedValue set
to how old they are. I have 2 validators (MinimumValidator(18) for adults,
and MaximumValidator(17) for minors) that need to be added dynamically based
on the DropDownChoice (adult vs. minor). So my code is dynamically doing
FormComponentPanel.add(---min or max validator--).

However, if a user selects minor from the first dropdown, and the other
dropdowns with a birthday that puts them at, say age 30.. I will get a form
validation error - which is good since the Maximum validator kicked in for
minors. But if I change the dropdown from minor to adult, the code does a
removeAll() (which should remove all children from FormComponentPanel),
readds the drop down, and then adds the MinimumValidator(18). At this point,
it seems like both validators are still in effect - so this is:

1. Clunky
2. Doesn't work (the minimum validator seems to still be there even after a
removeAll, which makes ANY birthday selection at this point invalid since
both validators are in effect)

Any ideas on how to remove validators or best approach this? The crux of the
problem is I want to switch the Component's validator from one, to another.

Thanks,
Tony


How to get Log Level: DEBUG?

2010-01-21 Thread Tony Wu
Can someone point me in the right direction for setting the default console
log output to include DEBUG level messages? It's currently showing INFO and
WARN only. I'm using the default maven generated project. Can I do something
like System.setProperty("org.apache.wicket.level", "DEBUG"); in
WicketApplication's init() - I tried that but it didn't seem to work?

Thanks,
Tony


Custom error messages for fields inside Fragments

2010-01-21 Thread Tony Wu
I have a PatternValidator and cannot figure out what is the correct path to
target a custom error message (page.properties) to a field inside a
fragment. Here's the markup: http://pastebin.com/m4c4744e3

I tried targeting:
zones.fullRecord.recordForm.fragment.insuranceFragment.insuranceProvider.PatternValidator=Custom
text
And also:
zones.fullRecord.recordForm.insuranceFragment.insuranceProvider.PatternValidator=Custom
text
And also:
zones.fullRecord.recordForm.fragment.insuranceProvider.PatternValidator=Custom
text

But all 3 don't work, I get the ugly default error message in my
Feedbackpanel. What am I doing incorrectly?

The code flow is:

PageConstructor {

add(new ListView("zones"...
   @Override populateItem
   item.add(new ListView("fullRecord"...
  @Override populateItem
  item.add(Form recordForm = new Form("recordForm");
 recordForm.add(new Fragment("fragment", "insuranceFragment"

}


Strange Error - Forms inside Fragments inside Nested Repeaters

2010-01-15 Thread Tony Wu
Not sure if this is a bug or something I overlooked, but I get a strange cast 
exception (org.apache.wicket.markup.RawMarkup cannot be cast to 
org.apache.wicket.markup.ComponentTag) when I have create a Form in a Fragment, 
which is inside a ListView, inside another ListView. Here's the exception: 
http://pastebin.com/d235de7b4

Here's the fragment markup, fragment Java code, and exception name: 
http://pastebin.com/d3ba85ea0

Very simple.. if I move the Form outside of the fragment into the ListView, 
then all is well.

Thoughts?

Thanks,
Tony
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org