Re: onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-27 Thread Ian MacLarty
I tried the fix to populateItem proposed by the original bug reporter
(http://issues.apache.org/jira/browse/WICKET-2384) and that seems to
work.

On Thu, Aug 27, 2009 at 4:32 PM, Igor Vaynbergigor.vaynb...@gmail.com wrote:
 well, its either removing components or an outofmemoryexception. which
 one do you prefer? :)

 we need to find another way to fix the OOME. can you see one?

 -igor

 On Wed, Aug 26, 2009 at 10:48 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Here is an example of some less trivial behaviour that is done when
 you click an error.  This changes to a specific tab that contains the
 erroneous field.  The error message that has this behaviour is added
 with some custom validation.

                   �...@override
                    protected void onClick(AjaxRequestTarget target) {
                        boolean fieldSelected = false;
                        TabbedPanel mainTabs =
 (TabbedPanel)container.findParent(TabbedPanel.class);
                        if (mainTabs != null) {
                            mainTabs.setSelectedTab(0); // Go to general tab.
                            target.addComponent(mainTabs);

 target.appendJavascript(adjust_feedback_panel_size(););
                            Component clientDOB =
 mainTabs.get(panel:client.dateOfBirth);
                            if
 (subj.equals(thisModel.getClient().getResource().toString())) {
                                target.appendJavascript($('# +
 clientDOB.getMarkupId() +
                                    ').addClass('error').select(););
                                fieldSelected = true;
                            }
                            if
 (Nulls.falseIfNull(thisModel.getClient().getHasPartner())) {
                                Component partnerDOB =
 mainTabs.get(panel:client.partner.dateOfBirth);
                                if
 (subj.equals(thisModel.getClient().getPartner().getResource().toString()))
 {
                                    String JS = $('# +
 partnerDOB.getMarkupId() + ').addClass('error');
                                    if (! fieldSelected) {
                                        JS += .select();;
                                    } else {
                                        JS += ;;
                                    }
                                    target.appendJavascript(JS);
                                }
                            }
                        }
                    }

 This would not very easy to implement as Javascript.

 On Thu, Aug 27, 2009 at 3:37 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 it doesnt really look like you need a callback, you can simply
 represent the link as a webmarkupcontainer that adds an onclick
 javascript. more efficient and does the same thing.

 -igor

 On Wed, Aug 26, 2009 at 10:11 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 It depends on the error.  Most of the time the onclick behaviour
 simply returns some javascript that highlights the invalid field.
 Sometimes it changes the current tab, because the invalid field is on
 a different tab.  The code looks like this:

        add(new AjaxEventBehavior(onclick) {
           �...@override
            protected void onEvent(AjaxRequestTarget target) {
                target.appendJavascript(onClickJS);
                if (msg instanceof PfpFeedbackMessage) {
                    PfpFeedbackMessage pfpMsg = (PfpFeedbackMessage)msg;
                    if (pfpMsg.getExtraClickBehavior() != null) {
                        pfpMsg.getExtraClickBehavior().onClick(target);
                    }
                }
            }
        });

 The getExtraClickBehaviour method can return any extra behaviour to do
 when the message is clicked (e.g. change the current tab).

 On Thu, Aug 27, 2009 at 3:01 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 what do these links do?

 -igor

 On Wed, Aug 26, 2009 at 9:51 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 Hi Igor,

 The commit log is simply:

 Issue: WICKET-2384.


 From http://issues.apache.org/jira/browse/WICKET-2384:

 Problem is that we keep reference to FeedbackMessage in component
 inside MessageListView item. The feedback message references previous
 page - that causes the problem, because the previous page is
 serialized together with current (and the page before, etc).

 Simply removing components from MessageListView should fix the problem.

 class MessageListView
 {
  ...
 �...@override
  protected void onDetach()
  {
    removeAll();
    super.onDetach();
  }

 }


 By the way if you have any suggestions on how I could work around my
 problem without having to go back to 1.3.6 I'd love to hear them.

 Cheers,
 Ian.

 On Thu, Aug 27, 2009 at 2:43 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 before you file a bug report, what was the commit log for that svn
 change you found?

 -igor

 On Wed, Aug 26, 2009 at 9:42 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 On Thu, Aug 27, 

Re: onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-27 Thread Ian MacLarty
BTW I've logged bug 2438.

On Thu, Aug 27, 2009 at 5:01 PM, Ian MacLartyian.macla...@gmail.com wrote:
 I tried the fix to populateItem proposed by the original bug reporter
 (http://issues.apache.org/jira/browse/WICKET-2384) and that seems to
 work.

 On Thu, Aug 27, 2009 at 4:32 PM, Igor Vaynbergigor.vaynb...@gmail.com wrote:
 well, its either removing components or an outofmemoryexception. which
 one do you prefer? :)

 we need to find another way to fix the OOME. can you see one?

 -igor

 On Wed, Aug 26, 2009 at 10:48 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Here is an example of some less trivial behaviour that is done when
 you click an error.  This changes to a specific tab that contains the
 erroneous field.  The error message that has this behaviour is added
 with some custom validation.

                   �...@override
                    protected void onClick(AjaxRequestTarget target) {
                        boolean fieldSelected = false;
                        TabbedPanel mainTabs =
 (TabbedPanel)container.findParent(TabbedPanel.class);
                        if (mainTabs != null) {
                            mainTabs.setSelectedTab(0); // Go to general tab.
                            target.addComponent(mainTabs);

 target.appendJavascript(adjust_feedback_panel_size(););
                            Component clientDOB =
 mainTabs.get(panel:client.dateOfBirth);
                            if
 (subj.equals(thisModel.getClient().getResource().toString())) {
                                target.appendJavascript($('# +
 clientDOB.getMarkupId() +
                                    ').addClass('error').select(););
                                fieldSelected = true;
                            }
                            if
 (Nulls.falseIfNull(thisModel.getClient().getHasPartner())) {
                                Component partnerDOB =
 mainTabs.get(panel:client.partner.dateOfBirth);
                                if
 (subj.equals(thisModel.getClient().getPartner().getResource().toString()))
 {
                                    String JS = $('# +
 partnerDOB.getMarkupId() + ').addClass('error');
                                    if (! fieldSelected) {
                                        JS += .select();;
                                    } else {
                                        JS += ;;
                                    }
                                    target.appendJavascript(JS);
                                }
                            }
                        }
                    }

 This would not very easy to implement as Javascript.

 On Thu, Aug 27, 2009 at 3:37 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 it doesnt really look like you need a callback, you can simply
 represent the link as a webmarkupcontainer that adds an onclick
 javascript. more efficient and does the same thing.

 -igor

 On Wed, Aug 26, 2009 at 10:11 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 It depends on the error.  Most of the time the onclick behaviour
 simply returns some javascript that highlights the invalid field.
 Sometimes it changes the current tab, because the invalid field is on
 a different tab.  The code looks like this:

        add(new AjaxEventBehavior(onclick) {
           �...@override
            protected void onEvent(AjaxRequestTarget target) {
                target.appendJavascript(onClickJS);
                if (msg instanceof PfpFeedbackMessage) {
                    PfpFeedbackMessage pfpMsg = (PfpFeedbackMessage)msg;
                    if (pfpMsg.getExtraClickBehavior() != null) {
                        pfpMsg.getExtraClickBehavior().onClick(target);
                    }
                }
            }
        });

 The getExtraClickBehaviour method can return any extra behaviour to do
 when the message is clicked (e.g. change the current tab).

 On Thu, Aug 27, 2009 at 3:01 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 what do these links do?

 -igor

 On Wed, Aug 26, 2009 at 9:51 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 Hi Igor,

 The commit log is simply:

 Issue: WICKET-2384.


 From http://issues.apache.org/jira/browse/WICKET-2384:

 Problem is that we keep reference to FeedbackMessage in component
 inside MessageListView item. The feedback message references previous
 page - that causes the problem, because the previous page is
 serialized together with current (and the page before, etc).

 Simply removing components from MessageListView should fix the problem.

 class MessageListView
 {
  ...
 �...@override
  protected void onDetach()
  {
    removeAll();
    super.onDetach();
  }

 }


 By the way if you have any suggestions on how I could work around my
 problem without having to go back to 1.3.6 I'd love to hear them.

 Cheers,
 Ian.

 On Thu, Aug 27, 2009 at 2:43 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 before you file a bug report, what was the commit log for that svn
 change you found?

 

onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-26 Thread Ian MacLarty
Hi,

I recently upgraded to Wicket 1.4 and am now having a problem with a
feedback panel.

I have a custom feedback panel that uses custom message components (by
overriding FeedbackPanel#newMessageDisplayComponent).  The custom
messages have an AjaxEventBehavior on the onclick event.  This
highlights the reporting component when the feedback message is
clicked.  This all worked okay in 1.3.6, but after upgrading to 1.4
Wicket throws a RuntimeException when the feedback message is clicked.
 The exception is component
mainForm:feedback:feedbackul:messages:0:message not found on page
axa.pfp.MainTabs.  If I look in the generated html this component
definitely seems to be there.  Does anyone know what might have
changed with version 1.4 to break this?

Many thanks,
Ian.

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



Re: onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-26 Thread Ian MacLarty
On Thu, Aug 27, 2009 at 1:41 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Hi,

 I recently upgraded to Wicket 1.4 and am now having a problem with a
 feedback panel.

 I have a custom feedback panel that uses custom message components (by
 overriding FeedbackPanel#newMessageDisplayComponent).  The custom
 messages have an AjaxEventBehavior on the onclick event.  This
 highlights the reporting component when the feedback message is
 clicked.  This all worked okay in 1.3.6, but after upgrading to 1.4
 Wicket throws a RuntimeException when the feedback message is clicked.
  The exception is component
 mainForm:feedback:feedbackul:messages:0:message not found on page
 axa.pfp.MainTabs.  If I look in the generated html this component
 definitely seems to be there.  Does anyone know what might have
 changed with version 1.4 to break this?


I suspect it is the change made in revision 796389:

Index: 
wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java
===
--- wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java 
(revision
796388)
+++ wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java 
(revision
796389)
@@ -94,6 +94,13 @@
listItem.add(levelModifier);
listItem.add(label);
}
+
+   @Override
+   protected void onDetach()
+   {
+   removeAll();
+   super.onDetach();
+   }
}

private static final long serialVersionUID = 1L;

The removeAll is removing all the child elements of the feedback
message list, which explains why it is not finding the component.

Should I log a bug report for this?  If this is the way it's supposed
to behave then how should I go about adding an onclick behaviour to my
feedback messages?

Cheers,
Ian.

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



Re: onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-26 Thread Ian MacLarty
On Thu, Aug 27, 2009 at 2:09 PM, Ian MacLartyian.macla...@gmail.com wrote:
 On Thu, Aug 27, 2009 at 1:41 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Hi,

 I recently upgraded to Wicket 1.4 and am now having a problem with a
 feedback panel.

 I have a custom feedback panel that uses custom message components (by
 overriding FeedbackPanel#newMessageDisplayComponent).  The custom
 messages have an AjaxEventBehavior on the onclick event.  This
 highlights the reporting component when the feedback message is
 clicked.  This all worked okay in 1.3.6, but after upgrading to 1.4
 Wicket throws a RuntimeException when the feedback message is clicked.
  The exception is component
 mainForm:feedback:feedbackul:messages:0:message not found on page
 axa.pfp.MainTabs.  If I look in the generated html this component
 definitely seems to be there.  Does anyone know what might have
 changed with version 1.4 to break this?


 I suspect it is the change made in revision 796389:

 Index: 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java
 ===
 --- 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java 
 (revision
 796388)
 +++ 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java 
 (revision
 796389)
 @@ -94,6 +94,13 @@
                        listItem.add(levelModifier);
                        listItem.add(label);
                }
 +
 +               @Override
 +               protected void onDetach()
 +               {
 +                       removeAll();
 +                       super.onDetach();
 +               }
        }

        private static final long serialVersionUID = 1L;

 The removeAll is removing all the child elements of the feedback
 message list, which explains why it is not finding the component.


Sure enough, if I comment out the removeAll() I don't get the problem.
 I guess I will file a bug report...

Ian.

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



Re: onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-26 Thread Ian MacLarty
Hi Igor,

The commit log is simply:

Issue: WICKET-2384.


From http://issues.apache.org/jira/browse/WICKET-2384:

Problem is that we keep reference to FeedbackMessage in component
inside MessageListView item. The feedback message references previous
page - that causes the problem, because the previous page is
serialized together with current (and the page before, etc).

Simply removing components from MessageListView should fix the problem.

class MessageListView
{
  ...
  @Override
  protected void onDetach()
  {
removeAll();
super.onDetach();
  }

}


By the way if you have any suggestions on how I could work around my
problem without having to go back to 1.3.6 I'd love to hear them.

Cheers,
Ian.

On Thu, Aug 27, 2009 at 2:43 PM, Igor Vaynbergigor.vaynb...@gmail.com wrote:
 before you file a bug report, what was the commit log for that svn
 change you found?

 -igor

 On Wed, Aug 26, 2009 at 9:42 PM, Ian MacLartyian.macla...@gmail.com wrote:
 On Thu, Aug 27, 2009 at 2:09 PM, Ian MacLartyian.macla...@gmail.com wrote:
 On Thu, Aug 27, 2009 at 1:41 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Hi,

 I recently upgraded to Wicket 1.4 and am now having a problem with a
 feedback panel.

 I have a custom feedback panel that uses custom message components (by
 overriding FeedbackPanel#newMessageDisplayComponent).  The custom
 messages have an AjaxEventBehavior on the onclick event.  This
 highlights the reporting component when the feedback message is
 clicked.  This all worked okay in 1.3.6, but after upgrading to 1.4
 Wicket throws a RuntimeException when the feedback message is clicked.
  The exception is component
 mainForm:feedback:feedbackul:messages:0:message not found on page
 axa.pfp.MainTabs.  If I look in the generated html this component
 definitely seems to be there.  Does anyone know what might have
 changed with version 1.4 to break this?


 I suspect it is the change made in revision 796389:

 Index: 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java
 ===
 --- 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java 
 (revision
 796388)
 +++ 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java 
 (revision
 796389)
 @@ -94,6 +94,13 @@
                        listItem.add(levelModifier);
                        listItem.add(label);
                }
 +
 +               @Override
 +               protected void onDetach()
 +               {
 +                       removeAll();
 +                       super.onDetach();
 +               }
        }

        private static final long serialVersionUID = 1L;

 The removeAll is removing all the child elements of the feedback
 message list, which explains why it is not finding the component.


 Sure enough, if I comment out the removeAll() I don't get the problem.
  I guess I will file a bug report...

 Ian.

 -
 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



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



Re: onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-26 Thread Ian MacLarty
It depends on the error.  Most of the time the onclick behaviour
simply returns some javascript that highlights the invalid field.
Sometimes it changes the current tab, because the invalid field is on
a different tab.  The code looks like this:

add(new AjaxEventBehavior(onclick) {
@Override
protected void onEvent(AjaxRequestTarget target) {
target.appendJavascript(onClickJS);
if (msg instanceof PfpFeedbackMessage) {
PfpFeedbackMessage pfpMsg = (PfpFeedbackMessage)msg;
if (pfpMsg.getExtraClickBehavior() != null) {
pfpMsg.getExtraClickBehavior().onClick(target);
}
}
}
});

The getExtraClickBehaviour method can return any extra behaviour to do
when the message is clicked (e.g. change the current tab).

On Thu, Aug 27, 2009 at 3:01 PM, Igor Vaynbergigor.vaynb...@gmail.com wrote:
 what do these links do?

 -igor

 On Wed, Aug 26, 2009 at 9:51 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Hi Igor,

 The commit log is simply:

 Issue: WICKET-2384.


 From http://issues.apache.org/jira/browse/WICKET-2384:

 Problem is that we keep reference to FeedbackMessage in component
 inside MessageListView item. The feedback message references previous
 page - that causes the problem, because the previous page is
 serialized together with current (and the page before, etc).

 Simply removing components from MessageListView should fix the problem.

 class MessageListView
 {
  ...
 �...@override
  protected void onDetach()
  {
    removeAll();
    super.onDetach();
  }

 }


 By the way if you have any suggestions on how I could work around my
 problem without having to go back to 1.3.6 I'd love to hear them.

 Cheers,
 Ian.

 On Thu, Aug 27, 2009 at 2:43 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 before you file a bug report, what was the commit log for that svn
 change you found?

 -igor

 On Wed, Aug 26, 2009 at 9:42 PM, Ian MacLartyian.macla...@gmail.com wrote:
 On Thu, Aug 27, 2009 at 2:09 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 On Thu, Aug 27, 2009 at 1:41 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 Hi,

 I recently upgraded to Wicket 1.4 and am now having a problem with a
 feedback panel.

 I have a custom feedback panel that uses custom message components (by
 overriding FeedbackPanel#newMessageDisplayComponent).  The custom
 messages have an AjaxEventBehavior on the onclick event.  This
 highlights the reporting component when the feedback message is
 clicked.  This all worked okay in 1.3.6, but after upgrading to 1.4
 Wicket throws a RuntimeException when the feedback message is clicked.
  The exception is component
 mainForm:feedback:feedbackul:messages:0:message not found on page
 axa.pfp.MainTabs.  If I look in the generated html this component
 definitely seems to be there.  Does anyone know what might have
 changed with version 1.4 to break this?


 I suspect it is the change made in revision 796389:

 Index: 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java
 ===
 --- 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java
  (revision
 796388)
 +++ 
 wicket/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java
  (revision
 796389)
 @@ -94,6 +94,13 @@
                        listItem.add(levelModifier);
                        listItem.add(label);
                }
 +
 +               @Override
 +               protected void onDetach()
 +               {
 +                       removeAll();
 +                       super.onDetach();
 +               }
        }

        private static final long serialVersionUID = 1L;

 The removeAll is removing all the child elements of the feedback
 message list, which explains why it is not finding the component.


 Sure enough, if I comment out the removeAll() I don't get the problem.
  I guess I will file a bug report...

 Ian.

 -
 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



 -
 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



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

Re: onclick AjaxEventBehaviour on feedback messages broken in 1.4?

2009-08-26 Thread Ian MacLarty
Here is an example of some less trivial behaviour that is done when
you click an error.  This changes to a specific tab that contains the
erroneous field.  The error message that has this behaviour is added
with some custom validation.

@Override
protected void onClick(AjaxRequestTarget target) {
boolean fieldSelected = false;
TabbedPanel mainTabs =
(TabbedPanel)container.findParent(TabbedPanel.class);
if (mainTabs != null) {
mainTabs.setSelectedTab(0); // Go to general tab.
target.addComponent(mainTabs);

target.appendJavascript(adjust_feedback_panel_size(););
Component clientDOB =
mainTabs.get(panel:client.dateOfBirth);
if
(subj.equals(thisModel.getClient().getResource().toString())) {
target.appendJavascript($('# +
clientDOB.getMarkupId() +
').addClass('error').select(););
fieldSelected = true;
}
if
(Nulls.falseIfNull(thisModel.getClient().getHasPartner())) {
Component partnerDOB =
mainTabs.get(panel:client.partner.dateOfBirth);
if
(subj.equals(thisModel.getClient().getPartner().getResource().toString()))
{
String JS = $('# +
partnerDOB.getMarkupId() + ').addClass('error');
if (! fieldSelected) {
JS += .select();;
} else {
JS += ;;
}
target.appendJavascript(JS);
}
}
}
}

This would not very easy to implement as Javascript.

On Thu, Aug 27, 2009 at 3:37 PM, Igor Vaynbergigor.vaynb...@gmail.com wrote:
 it doesnt really look like you need a callback, you can simply
 represent the link as a webmarkupcontainer that adds an onclick
 javascript. more efficient and does the same thing.

 -igor

 On Wed, Aug 26, 2009 at 10:11 PM, Ian MacLartyian.macla...@gmail.com wrote:
 It depends on the error.  Most of the time the onclick behaviour
 simply returns some javascript that highlights the invalid field.
 Sometimes it changes the current tab, because the invalid field is on
 a different tab.  The code looks like this:

        add(new AjaxEventBehavior(onclick) {
           �...@override
            protected void onEvent(AjaxRequestTarget target) {
                target.appendJavascript(onClickJS);
                if (msg instanceof PfpFeedbackMessage) {
                    PfpFeedbackMessage pfpMsg = (PfpFeedbackMessage)msg;
                    if (pfpMsg.getExtraClickBehavior() != null) {
                        pfpMsg.getExtraClickBehavior().onClick(target);
                    }
                }
            }
        });

 The getExtraClickBehaviour method can return any extra behaviour to do
 when the message is clicked (e.g. change the current tab).

 On Thu, Aug 27, 2009 at 3:01 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 what do these links do?

 -igor

 On Wed, Aug 26, 2009 at 9:51 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Hi Igor,

 The commit log is simply:

 Issue: WICKET-2384.


 From http://issues.apache.org/jira/browse/WICKET-2384:

 Problem is that we keep reference to FeedbackMessage in component
 inside MessageListView item. The feedback message references previous
 page - that causes the problem, because the previous page is
 serialized together with current (and the page before, etc).

 Simply removing components from MessageListView should fix the problem.

 class MessageListView
 {
  ...
 �...@override
  protected void onDetach()
  {
    removeAll();
    super.onDetach();
  }

 }


 By the way if you have any suggestions on how I could work around my
 problem without having to go back to 1.3.6 I'd love to hear them.

 Cheers,
 Ian.

 On Thu, Aug 27, 2009 at 2:43 PM, Igor Vaynbergigor.vaynb...@gmail.com 
 wrote:
 before you file a bug report, what was the commit log for that svn
 change you found?

 -igor

 On Wed, Aug 26, 2009 at 9:42 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 On Thu, Aug 27, 2009 at 2:09 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 On Thu, Aug 27, 2009 at 1:41 PM, Ian MacLartyian.macla...@gmail.com 
 wrote:
 Hi,

 I recently upgraded to Wicket 1.4 and am now having a problem with a
 feedback panel.

 I have a custom feedback panel that uses custom message components (by
 overriding FeedbackPanel#newMessageDisplayComponent).  The custom
 messages have an AjaxEventBehavior on the onclick event.  This
 highlights the reporting component when the feedback 

Re: model detached many times

2009-07-13 Thread Ian MacLarty
On Mon, Jul 13, 2009 at 9:43 PM, James
Carmanjcar...@carmanconsulting.com wrote:
 On Mon, Jul 13, 2009 at 7:32 AM, Erik van Oostene.vanoos...@grons.nl wrote:
 So the best thing to do for now is to have some flag to see if you're
 already detached. In getObject the flag is cleared. For most models however,
 it should not matter if they're called multiple times; the typical thing you
 do in detach is set a field to null.

 Some models could do some weird stuff like remove connections to
 resources, though, on detach.


I close a connection to another server on detach.   I null out the
connection field after closing it though, so I never close it twice.

Ian.

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



Re: model detached many times

2009-07-12 Thread Ian MacLarty
On Fri, Jul 10, 2009 at 6:00 PM, Martijn
Dashorstmartijn.dasho...@gmail.com wrote:
 If you share a model between components, then yes–each component will
 call detach on the model. That's encapsulation for you: one component
 doesn't know about another component, so it can't know that its model
 was detached.


Okay, thanks for clearing that up.

Ian.

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



model detached many times

2009-07-10 Thread Ian MacLarty
Hi,

I noticed that my IDetachable model is being detached many times
(hundreds) for each request.  Is that something to worry about, or is
it just because the detach method is called for each component that
points to this model?

Ian.

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



Re: model detached many times

2009-07-10 Thread Ian MacLarty
I put a breakpoint on the detach method of my model and had a look at
the Components whose detach methods were called higher up in the stack
trace.  It looks like the detach method on the model is being called
for every component on the page.  All the components link to the same
underlying model via a CompoundPropertyModel, so I guess lots of calls
to the detach method of the model should be expected?

Ian.

On Fri, Jul 10, 2009 at 5:17 PM, Eelco
Hilleniuseelco.hillen...@gmail.com wrote:
 It's fine if a model if detached multiple times in a request, but
 hundreds for a single model sounds suspicious. Try to trace what
 components fire the detach method and see if there's anything weird
 with that.

 Eelco

 On Thu, Jul 9, 2009 at 11:21 PM, Ian MacLartyian.macla...@gmail.com wrote:
 Hi,

 I noticed that my IDetachable model is being detached many times
 (hundreds) for each request.  Is that something to worry about, or is
 it just because the detach method is called for each component that
 points to this model?

 Ian.

 -
 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



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



changing locale with a form

2009-07-08 Thread Ian MacLarty
Hi,

I'm trying to implement a page containing a form and some links that
allow the user to change the current locale.

Unlike the example at
http://www.wicket-library.com/wicket-examples/forminput/ I do not want
the form values to be reset when the user changes the locale.

The first thing I tried was SubmitLinks where I changed the locale in
the onSubmit method.  This had that the problem that if there was a
validation error, the locale would not be changed.

So then what I did was to call setDefaultFormProcessing(false) on the
SubmitLinks.  This all seemed to work until I noticed a rather subtle
bug.  One of the fields on the form was a Float.  Let's say I entered
a value of 3000 into this field and submitted the form.  Suppose the
current locale was English.  Now the value would be displayed as
3,000.   Now suppose I change the language to Dutch.  The display
value would remain 3,000.  Now when I submit the form the model is
updated to 3.0, because the decimal point in the Dutch locale is a
comma and not a period.

With my third attempt I used a SubmitLink that looks like the following:

mainForm.add(new SubmitLink(nl) {
@Override
public void onSubmit() {
getMainForm().process();
setLanguage(nl);
}
}.setDefaultFormProcessing(false));

So, I bypass default form processing so that I can set the locale
regardless of whether the form validated or not.  So the user can
change locale even if there are validation errors.  It also means that
the model is updated before the locate is changed, so I don't have the
float conversion problem I described above.

I still have a problem though.  The problem is that if there are
validation errors, then they are displayed using the old language and
not the new language the user has just changed to.  For example if the
user changes from English to Dutch and there is a validation error,
the error will be displayed in English, while the rest of the page is
rendered in Dutch.

Does anyone know how I can fix this?

I think the problem is that the validation error message string is
resolved when the validation error is added to the component.  If it
were resolved just before the page was rendered I think my code would
work.

Ian.

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



Re: question about IChoiceRenderer#getIdValue

2009-06-08 Thread Ian MacLarty
On Tue, Jun 9, 2009 at 11:23 AM, Igor Vaynbergigor.vaynb...@gmail.com wrote:
 no its not really safe if the changes to locale resort the list.


Okay, thanks.

Ian.

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



Re: shorter input names

2009-05-18 Thread Ian MacLarty
Hi Jan,

Thanks for that.  For your solution to work it looks like wicket would
need to only call getInputName at most once for each input (since
subsequent calls would return different names).  Is that how it works?

I'm still learning Scala, but so far I find it a compelling alternative to Java.

Cheers,
Ian.

On Mon, May 18, 2009 at 3:10 PM, Jan Kriesten
kries...@mail.footprint.de wrote:

 Hi Ian,

 Is there a way to get wicket to generate shorter name attributes for
 input elements?  I have a largish form and most of the data being sent
 to the server is the names of the input elements.

 it is by overriding the method 'getInputName' on every FormComponent and
 returning a stable identifier over requests - though this is pretty horrible
 task to do.

 If you're using Scala instead of Java things are getting better, though. I
 defined the following trait (aka implemented interface):

 ---
 object FormInputNameId {
  private var currId = 0

  private def getName = {
    if( currId==Integer.MAX_VALUE-1 ) currId=1 else currId = currId + 1
    fid: + currId
  }
 }

 trait FormInputNameId[T] extends FormComponent[T] {
  override val getInputName: String = FormInputNameId.getName
 }
 ---

 This trait can be attached to any FormComponent with just something like

 val newFormComponent = new TextField( id ) with FormInputNameId

 The Scala compiler does the rest for you (one of my favorite features of Scala
 to have real reusable code!).

 Best regards, --- Jan.

 -
 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: shorter input names

2009-05-18 Thread Ian MacLarty
On Mon, May 18, 2009 at 4:44 PM, Jan Kriesten
kries...@mail.footprint.de wrote:

 Hi Ian,

 Thanks for that.  For your solution to work it looks like wicket would
 need to only call getInputName at most once for each input (since
 subsequent calls would return different names).  Is that how it works?

 no, within the trait I override the 'def getInputName' from Wicket with a 'val
 getInputName' - i.e. even when Wicket is calling it more than once it is still
 only evaluated once. That's another nice thing Scala provides... :-)


Ah!  Thanks for clarifying that.

Ian.

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



Re: How do you get a custom FormComponent to remember erroneous values?

2009-05-18 Thread Ian MacLarty
On Mon, May 18, 2009 at 4:38 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 In onbeforerender you should init the modelobkect not the model.

 But in your simple case you dont even need onbrforwrender, instead:
 new textfield(..., new propertymodel(this,model)). Done.


Awesome. Thanks!

Ian.

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



How do you get a custom FormComponent to remember erroneous values?

2009-05-17 Thread Ian MacLarty
Hi,

If I have a TextField whose model object is a Float, then if the user
enters an invalid value, say aaa,  the TextField will remember that
invalid value and display it when the page is re-rendered.  How would
you go about getting the same behaviour for a custom FormComponent?

Here is my simple custom FormComponent.

public class MyPanel extends FormComponentPanel {
TextField field;

public MyPanel(String id) {
super(id);
field = new TextField(f, Float.class);
add(field);
}

@Override
protected void convertInput() {
setConvertedInput(field.getConvertedInput());
}

@Override
protected void onBeforeRender() {
field.setModel(getModel());
super.onBeforeRender();
}
}

wicket:panel
input wicket:id=f type=text /
/wicket:panel

And here is how I use it:

public class HomePage extends WebPage {

private static final long serialVersionUID = 1L;

public HomePage(final PageParameters parameters) {
CompoundPropertyModel cpModel = new CompoundPropertyModel(this);
Form form = new Form(form, cpModel);
form.add(new TextField(field1, Float.class));
form.add(new MyPanel(field2));
add(form);
}

private Float field1 = 1.0f;
private Float field2 = 2.0f;

public Float getField1() {
return field1;
}

public void setField1(Float value) {
field1 = value;
}

public Float getField2() {
return field2;
}

public void setField2(Float value) {
field2 = value;
}
}

html
head
titleWicket Quickstart Archetype Homepage/title
/head
body
form wicket:id=form
input wicket:id=field1 type=text /
div wicket:id=field2 /
input type=submit value=Submit /
/form
/body
/html

If I run this and enter aaa for field1 and bbb for field2 and
submit the form, then when the page is re-rendered field1 still has
aaa, but field2 has been reset to 2.  I'm pretty sure the problem
is to do with the call to setModel in MyPanel#onBeforeRender, but I
don't know how else to link the FormComponent model with the model of
the TextField inside the FormComponent.

Any help would be greatly appreciated.  I'm using Wicket 1.3.5.

Cheers,
Ian.

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



Re: How do you get a custom FormComponent to remember erroneous values?

2009-05-17 Thread Ian MacLarty
Hi Martin,

On Sun, May 17, 2009 at 10:56 PM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 ... raw input? In my understanding it works by default.


Thanks for the hint.  I got it to work by modifying my onBeforeRender to be:

@Override
protected void onBeforeRender() {
if (!field.hasRawInput()) {
field.setModel(getModel());
}
super.onBeforeRender();
}

Could you confirm that this is the right fix?

Ian.

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



shorter input names

2009-05-17 Thread Ian MacLarty
Hi,

Is there a way to get wicket to generate shorter name attributes for
input elements?  I have a largish form and most of the data being sent
to the server is the names of the input elements.

Cheers,
Ian.

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



Re: How do you get a custom FormComponent to remember erroneous values?

2009-05-17 Thread Ian MacLarty
On Mon, May 18, 2009 at 2:07 PM, Martin Makundi
martin.maku...@koodaripalvelut.com wrote:
 Does not look right... but who am I to say. Why do you call
 field.setModel(getModel()) at all?


I have to set the model of the nested component somewhere.  I can't
set it in the constructor, because the model is not available then.
The documentation for FormComponentPanel suggests doing it in
onBeforeRender.

 I would leave it out alltogether (= not change model). If you have
 other reasons to change the model, then you can override the
 FormComponent.internalOnModelChanged:

                  /**
                   * @see
 org.apache.wicket.markup.html.form.FormComponent#internalOnModelChanged()
                   */
                 �...@override
                  protected void internalOnModelChanged() {
                    onValid(); // Do not clear input
                  }

The docs say not to override this method, so I'd rather not do that.

I found that if I initialized the nested component in onBeforeRender
with the model (making sure I do it only once), then I got the
behaviour I wanted.  I don't understand why that works though.

Ian.

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



Re: Changing form validation depending on submit button.

2009-04-13 Thread Ian MacLarty
On Fri, Apr 10, 2009 at 11:09 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 there is form#onvalidate()


You mean form#validate() I think.  Thanks for the pointer.

Ian.

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



Re: Changing form validation depending on submit button.

2009-04-09 Thread Ian MacLarty
On Thu, Apr 9, 2009 at 8:20 PM, John Krasnay j...@krasnay.ca wrote:
 Have a look here:

 http://cwiki.apache.org/WICKET/conditional-validation.html


Thanks.  That's pretty much what I ended up doing.  It seemed a bit
kludgy to be doing validation in the onSubmit method.  It means I
can't put my error handling code in onError where it should be.  Not a
big deal though.

Cheers,
Ian.

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



Changing form validation depending on submit button.

2009-04-08 Thread Ian MacLarty
Hi,

I have a form with two submit buttons.  I want the form to validate
differently depending on what submit button is pressed (i.e. I want to
use a different IFormValidator depending on what button is used to
submit the form).  How would I go about doing this?

Ian.

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



Re: dynamic component

2009-04-04 Thread Ian MacLarty
On Sat, Apr 4, 2009 at 2:16 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 create a formcomponentpanel, add a checkbox and a textfield and make
 only one of them visible.


I think I found a more elegant (and efficient?) way to do this if I
want to cover more than 2 model classes.

Instead of adding a component for each possible class in the
constructor and setting one of them to be visible in onBeforeRender, I
add only one component in onBeforeRender (it cannot be added in the
constructor, because I don't have access to the model at that point).
Once I've added the component I set a flag so that it isn't added
twice.

This seems to work, but I just wanted to check if there are any issues
with adding the component in onBeforeRender instead of the
constructor?

Here is the code (StringField and BooleanField are FormComponentPanels
with one TextField and CheckBox respectively):

public class DynamicComponent extends FormComponentPanel {
private FormComponent component;
private boolean initialized = false;

public DynamicComponent(String id) {
super(id);
}

public DynamicComponent(String id, IModel model) {
super(id, model);
}

@Override
protected void convertInput() {
setConvertedInput(component.getConvertedInput());
}

@Override
protected void onBeforeRender() {
IModel model = getModel();
if (!initialized) {
Class clazz;
if (model instanceof AbstractPropertyModel) {
// Get the type from the AbstractPropertyModel if we can,
// since that will work even if the value is null.
clazz = ((AbstractPropertyModel)model).getObjectClass();
} else {
Object modelVal = model.getObject();
if (modelVal != null) {
clazz = modelVal.getClass();
} else {
clazz = String.class;
}
}
if (clazz.equals(String.class)) {
component = new StringField(component, model);
} else if (clazz.equals(Boolean.class)) {
component = new BooleanField(component, model);
} else {
throw new RuntimeException(Unhandled type:  + clazz);
}
add(component);
initialized = true;
}
super.onBeforeRender();
}
}

Cheers,
Ian.

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



Re: dynamic component

2009-04-04 Thread Ian MacLarty
On Sun, Apr 5, 2009 at 12:03 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 the reason i suggested adding both is that the builtin textfiend and
 checkbox components check the input type of the markup they are
 attached to, so textfield can only be attached to type=text and
 checkbox to type=checkbox. since you are not using the builtin
 components it looks like, you can safely do what you are.


Cool, thanks for your help.

Ian.

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



dynamic component

2009-04-03 Thread Ian MacLarty
Hello,

I'd like to create a Component that behaves like a CheckBox if its
model is a Boolean and a TextField if its model is a String.  I'd like
to be able to add the component to a form with a
CompoundPropertyModel, just like you can with a CheckBox or TextField.
 How would you go about creating such a component?

Cheers,
Ian.

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



Re: dynamic component

2009-04-03 Thread Ian MacLarty
On Sat, Apr 4, 2009 at 3:16 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 create a formcomponentpanel, add a checkbox and a textfield and make
 only one of them visible.


Thanks.

Ian.

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