Select CheckGroup with Button instead of CheckGroupSelector

2008-01-23 Thread thomas jaeckle

Hi.

I want to select all Checkboxes in a CheckGroup with a Button.
Therefore I looked at CheckGroupSelector and came up with this:

public class CheckGroupButtonSelectAll extends Button
{
   public CheckGroupButtonSelectAll(String id)
   {
  super(id);
  setDefaultFormProcessing(false);
   }

   protected void onComponentTag(ComponentTag tag)
   {
  checkComponentTag(tag, input);

  CheckGroup group = (CheckGroup) findParent(CheckGroup.class);

  tag.put(onclick, var cb=this.form[' + group.getInputName()
+ ']; if (cb!=null) { if (!isNaN(cb.length)) { for(var
i=0;icb.length;i++) { cb[i].checked=true; } } });

  super.onComponentTag(tag);
   }
}


The Problem: All Checkboxes get selected after click on the Button, but
right after that the DataTable refreshes and the selections are lost again.

I also tried to extend from AjaxButton and append the javascript in the
onSubmit, but then i can't use  this.form[' + group.getInputName() + '] 
to iterate over all checkboxes.


Any idea?
-- 
View this message in context: 
http://www.nabble.com/Select-CheckGroup-with-Button-instead-of-CheckGroupSelector-tp15039121p15039121.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]



Re: Select CheckGroup with Button instead of CheckGroupSelector

2008-01-23 Thread thomas jaeckle


Jonas-21 wrote:
 
 I think if you add 'return false;' to your javascript, the button's
 default click action (submitting
 a form) isn't executed, so your DataTable doesn't get refreshed.
 
That's brilliant and works perfect.
Thank you very much.

Here the working code:

public class CheckGroupButtonSelectAll extends Button
{
   public CheckGroupButtonSelectAll(String id)
   {
  super(id);
  setDefaultFormProcessing(false);
   }

   protected String getOnClickScript()
   {
  CheckGroup group = (CheckGroup) findParent(CheckGroup.class);
  return var cb=this.form[' + group.getInputName()
+ ']; if (cb!=null) { if (!isNaN(cb.length)) { for(var
i=0;icb.length;i++) { cb[i].checked=true; } } } return false;;
   }
}
-- 
View this message in context: 
http://www.nabble.com/Select-CheckGroup-with-Button-instead-of-CheckGroupSelector-tp15039121p15042108.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]



Re: How can I validate required formComponents after page load?

2008-01-11 Thread thomas jaeckle



igor.vaynberg wrote:
 
 onbeforerender {
   textfield.error(RequiredValidator.class.getSimpleName());
 }
 
 -igor
 
Thanks igor.

Now it is working fine with:

protected void onBeforeRender()
{
  super.onBeforeRender();

  visitChildren(FormComponent.class, new IVisitor()
  {
public Object component(Component component)
{
  FormComponent formComponent = (FormComponent) component;
  if (formComponent.isRequired())
  {
formComponent.error((IValidationError)new
ValidationError().addMessageKey(Required));
  }
  return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
   }
  });
}
-- 
View this message in context: 
http://www.nabble.com/How-can-I-validate-required-formComponents-after-page-load--tp14730931p14751493.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]



How can I validate required formComponents after page load?

2008-01-10 Thread thomas jaeckle

Hello Guys.

I am trying to validate my RequiredTextFields directly when/after the Page
is loaded so that I can display the required errormessage in my
feedbackpanel.

Currently I try to do this in the Pages constructor:

add(new AjaxEventBehavior(onload)
{
  protected void onEvent(AjaxRequestTarget target)
  {
fieldLastName.validate();
target.addComponent(getBorder().get(footerFeedback));
  }
});

But that doesn't work.

Any idea how to achieve that?


Thomas
-- 
View this message in context: 
http://www.nabble.com/How-can-I-validate-required-formComponents-after-page-load--tp14730931p14730931.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]



AjaxFormValidatingBehavior and caret (cursor) position

2008-01-10 Thread thomas jaeckle

Hi everyone.

I found this on the mailing list:
http://www.nabble.com/Re%3A-AjaxFormValidatingBehavior-and-focus-p9178324.html

And exactly this is my problem now.
I registered an onkeyup event on a textfield to validate it after each
keypress.

In a RequiredTextField following happens:
I want to type Hello. Once i release the H, the TextField is valid and
the caret goes to the first position in the Textfield. Then I type ello
and now I have elloH in the Textfield.

Is it planned to implement to keep the caret position as mentioned in the
other Message?
Does someone know a workaround to solve this?


Thomas
-- 
View this message in context: 
http://www.nabble.com/AjaxFormValidatingBehavior-and-caret-%28cursor%29-position-tp14732154p14732154.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]



Re: How can I validate required formComponents after page load?

2008-01-10 Thread thomas jaeckle



igor.vaynberg wrote:
 
 how about just page.onbeforerender() { fieldlastname.valdiate(); }
 
 -igor
 
Ok, thanks ..
But the RequiredTextField validates because it isn't added to the Page yet
(input is null and not an empty String) and so checkRequired() from
FormComponent returns true:

public boolean checkRequired()
{
  if (isRequired())
  {
final String input = getInput();

// when null, check whether this is natural for that component, or
// whether - as is the case with text fields - this can only happen
// when the component was disabled
if (input == null  !isInputNullable())
{
  // this value must have come from a disabled field
  // do not perform validation
  return true;
}

// peform validation by looking whether the value is null or empty
return !Strings.isEmpty(input);
  }
  return true;
}


Thomas
-- 
View this message in context: 
http://www.nabble.com/How-can-I-validate-required-formComponents-after-page-load--tp14730931p14750961.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]



Re: How to open a popup in onSubmit() of a Form

2007-12-21 Thread thomas jaeckle

Hi again.
I found a solution, but it isn't very nice:

First I implemented a AjaxForm like the AjaxButton is implemented (why isn't
there a AjaxForm delivered with Wicket?):

public abstract class AjaxForm extends Form
{
   public AjaxForm(String id)
   {
  super(id);

  add(new AjaxFormSubmitBehavior(this, onsubmit)
  {
 private static final long serialVersionUID = 1L;

 protected void onSubmit(AjaxRequestTarget target)
 {
AjaxForm.this.onSubmit(target);
 }

 protected void onError(AjaxRequestTarget target)
 {
AjaxForm.this.onError(target);
 }

 protected CharSequence getEventHandler()
 {
return new
AppendingStringBuffer(super.getEventHandler()).append(; return false;);
 }

 protected IAjaxCallDecorator getAjaxCallDecorator()
 {
return AjaxForm.this.getAjaxCallDecorator();
 }
  });
   }

   protected IAjaxCallDecorator getAjaxCallDecorator()
   {
  return null;
   }

   protected void onError(AjaxRequestTarget target)
   {
   }

   protected abstract void onSubmit(AjaxRequestTarget target);
}



Now I can do:

AjaxForm form = new AjaxForm(form)
{
   private static final long serialVersionUID = 1L;

   protected void onSubmit(AjaxRequestTarget target)
   {
  PopupSettings popupSettings = new PopupSettings(PageMap.forName(id_
+ textField.getConvertedInput()),
PopupSettings.RESIZABLE).setHeight(768).setWidth(1024);
  
  PageParameters tmpParameters = new PageParameters();
  tmpParameters.add(id, (String)
partnerSearchTextField.getConvertedInput());

   popupSettings.setTarget(' + urlFor(PrBrsPage.class,
tmpParameters).toString() + ');

   final String orgPopupString = popupSettings.getPopupJavaScript();
   int i = orgPopupString.indexOf(return false;);
   String popupString = popupSettings.getPopupJavaScript().substring(0,
i-1);

   if (target != null)
   {
  target.appendJavascript(popupString);
  // focusComponent(null) to prevent that the main window regains
focus
  target.focusComponent(null);
   }
   }
};


But I don't really like this solution. If someone has an idea how to make
this nicer, please speak ;)

regards Thomas
-- 
View this message in context: 
http://www.nabble.com/How-to-open-a-popup-in-onSubmit%28%29-of-a-Form-tp14435932p14452239.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]



Re: How to open a popup in onSubmit() of a Form

2007-12-21 Thread thomas jaeckle



Thomas Kappler-2 wrote:
 
 Do you know about
 org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow?  It
 seems to do almost what you want, or at least you can look at the
 source.
 
 Cheers,
 Thomas
 
Thanks for the tip.
But at this place I don't want a ModalWindow, a want a normal popup.
And my problem would also remain with a ModalWindow: how can I open a new
ModalWindow in onSubmit() of a form?

Thomas
-- 
View this message in context: 
http://www.nabble.com/How-to-open-a-popup-in-onSubmit%28%29-of-a-Form-tp14435932p14454415.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]



How to open a popup in onSubmit() of a Form

2007-12-20 Thread thomas jaeckle

Hello.

I am trying to open a popup in onSubmit() of a form.
The form is simple: it has a TextField and a Button. 
When it is submitted the value from the TextField shall become a
PageParameter for the popup and it shall be used in PageMap.forName(...) as
identifier (so for equal values the created Pages are loaded in the same
popup).

I only know how to open a Popup in a static way - with a Link that knows at
Page creation time what popup it should load and with which PageParameters.

I came up with something like that:

Form form = new Form(form)
{
  protected void onSubmit()
  {
PopupSettings popupSettings = new PopupSettings(PageMap.forName(id_
  + textField.getConvertedInput())).setHeight(768).setWidth(1024);

System.out.println(popupSettings.getPopupJavaScript());

PageParameters parameters = new PageParameters();
parameters.add(id, (String)textField.getConvertedInput());

// TODO ** open the Popup here with the pageParameters
  }
};

But I don't know if this is even the right direction.
Is this even possible?


regards Thomas
-- 
View this message in context: 
http://www.nabble.com/How-to-open-a-popup-in-onSubmit%28%29-of-a-Form-tp14435932p14435932.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]



Re: Problem with JavaScript when using Wicket AJAX Components

2007-12-20 Thread thomas jaeckle

I think I understand now, why the tooltips don't appear.
The JavaScript is initialized when the Page is initialized. At this time the
DataTable inside the AjaxLazyLoadPanel is not there.
The JavaScript iterates over all elements I have specified ('input', 'td',
'tr', 'textarea', 'select', 'span', 'div', 'a','abbr','acronym') and adds
events for them. But of course none of the DataTable - it is not there yet.

But how do I specify that the JavaScript is again executed after the
AjaxLazyLoadPanel has loaded the DataTable?


regards Thomas
-- 
View this message in context: 
http://www.nabble.com/Problem-with-JavaScript-when-using-Wicket-AJAX-Components-tp14432037p14438456.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]



Problem with JavaScript when using Wicket AJAX Components

2007-12-19 Thread thomas jaeckle

Hi there.

I wanted to implement Tooltips for my DataTable as described in the Wiki: 
http://cwiki.apache.org/WICKET/how-to-add-tooltips.html

So in every page I want to use them I add this in the page constructor:
add(HeaderContributor.forCss(AbstractBorder.class,
resource/css/sweetTitles.css));
add(HeaderContributor.forJavaScript(AbstractBorder.class,
resource/js/addEvent.js));
add(HeaderContributor.forJavaScript(AbstractBorder.class,
resource/js/sweetTitles.js));

The sweetTitles tooltips are working if I add the DataTable directly to the
page.
But they are not working for the table when I use a AjaxLazyLoadPanel
around the DataTable (for other Components on the Page that are outside the
AjaxLazyLoadPanel they are still working).

Or at another place I use a LinkTree and change a panel when it is clicked
on a node. I also added the add(HeaderContributor  stuff for the
WebPage with the LinkTree, but in the Panels I can't use the sweetTitles
tooltips.

When I look at the generated HTML-Code the JavaScript-Files are always
correctly in the header.
But why are they not working?

Any idea? Did I miss something?


Thomas
-- 
View this message in context: 
http://www.nabble.com/Problem-with-JavaScript-when-using-Wicket-AJAX-Components-tp14432037p14432037.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]



PagingNavigationIncrementLink special behaviour

2007-12-03 Thread thomas jaeckle

Hi there.

I implemented a AjaxFallbackDefaultDataTable which has a custom
AjaxNavigationToolbar with a custom AjaxPagingNavigator.
In this AjaxPagingNavigator I want that when the user clicks on  (which
is always enabled), more data from a service is loaded:

@Override
public void onClick(AjaxRequestTarget target)
{
   //  was clicked and no more pages available - load more data
   if (increment==1  isLast())
   {
  getDataProvider().update();
  pageable.setCurrentPage(getPageNumber());
  // pageable.setCurrentPage(getPageNumber()+1); // would throw
IndexOutOfBoundsException
   }
   else
   {
  super.onClick(target);
   }
}

So, this works perfectly, but the page is not changed to the new one,
because of PagingNavigationIncrementLink.getPageNumber() which is final:

   int idx = pageable.getCurrentPage() + increment;
   // make sure the index lies between 0 and the last page
   return Math.max(0, Math.min(pageable.getPageCount() - 1, idx));

It refers on pageable.getPageCount(), which has at this time still the old
amount of pages.

Any idea how to get around this?
Or can PagingNavigationIncrementLink.getPageNumber() be made not-final?


Thomas
-- 
View this message in context: 
http://www.nabble.com/PagingNavigationIncrementLink-special-behaviour-tf4935583.html#a14127228
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Problems with spring to manage all webpages

2007-11-21 Thread thomas jaeckle



igor.vaynberg wrote:
 
 make that bean a prototype?
 
Hm, I don't see the benefit of this. The problem remains:
I can't initialize the pages before the WebApplication is initialized (in
this case I would become a There is no application attached to current
thread main Exception). But when I initialize them lazy, they don't get
their attributes injected before Wicket displays the homePage ...
-- 
View this message in context: 
http://www.nabble.com/Problems-with-spring-to-manage-all-webpages-tf4844256.html#a13873117
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Problems with spring to manage all webpages

2007-11-20 Thread thomas jaeckle

Hi everyone.
I am trying to manage all of my WebPages via spring. 
Every page is derived from AbstractIndex which contains the Border (the
page layout: header, navigation):

public abstract class AbstractIndex extends WebPage {
  @SpringBean
  protected Border border;

  AbstractIndex(PageParameters parameters) {
super(parameters);

assert border!=null : border is NULL;
border.setTransparentResolver(true);
add(border);
  }
...
}

And an example page:

public class PortalPage extends AbstractIndex {
  public PortalPage(PageParameters parameters) {
super(parameters);
...
  }
...
}

In WicketApplication I have to set the homePage:

public class WicketApplication extends SpringWebApplication {
  public Class getHomePage() {
return PortalPage.class;
  }
}


Now the problem: I have to initialize all pages lazy (lazy-init=true) in
the Spring applicationContext, because they can be initialized only when
WicketApplication is running already in the main-thread.
But now in WicketApplication the homePage ist set - and the PortalPage (in
this case) has not yet been initialized, so the AssertionError (assert
border!=null : border is NULL;) from AbstractIndex is thrown.

It is a chicken-egg-problem ... at least I think so.
Does someone have an idea how to solve this? 


regards
Thomas
-- 
View this message in context: 
http://www.nabble.com/Problems-with-spring-to-manage-all-webpages-tf4844256.html#a13859451
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Problems with spring to manage all webpages

2007-11-20 Thread thomas jaeckle


Timo Rantalaiho wrote:
 
 Why are you trying to make Spring create your component
 instances? What benefit would that give?
 
The benefit would be that inhertitance and reusability is much easier to
manage.
If I go with straight Java, I have to create lots of more classes and the
code becomes uglier.

I came so far with Spring and wicket now that I can't believe that it isn't
possible ...
-- 
View this message in context: 
http://www.nabble.com/Problems-with-spring-to-manage-all-webpages-tf4844256.html#a13864455
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: How do I get the current page?

2007-11-06 Thread thomas jaeckle


Al Maw wrote:
 
 Just call Component#getPage()
 

Shame on me ...
I thought I tried that once and it didn't work back then ...
Looks like I did something wrong.

Tanks very much, Al


Thomas Jaeckle
-- 
View this message in context: 
http://www.nabble.com/How-do-I-get-the-current-page--tf4758474.html#a13608876
Sent from the Wicket - User mailing list archive at Nabble.com.


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