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 Vaynberg<[email protected]> 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 MacLarty<[email protected]> 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 Vaynberg<[email protected]> 
>> wrote:
>>> what do these links do?
>>>
>>> -igor
>>>
>>> On Wed, Aug 26, 2009 at 9:51 PM, Ian MacLarty<[email protected]> 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 Vaynberg<[email protected]> 
>>>> 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 MacLarty<[email protected]> 
>>>>> wrote:
>>>>>> On Thu, Aug 27, 2009 at 2:09 PM, Ian MacLarty<[email protected]> 
>>>>>> wrote:
>>>>>>> On Thu, Aug 27, 2009 at 1:41 PM, Ian MacLarty<[email protected]> 
>>>>>>> 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: [email protected]
>>>>>> For additional commands, e-mail: [email protected]
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [email protected]
>>>>> For additional commands, e-mail: [email protected]
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to