ajaxrequesttarget will now also call component.setmarkupid() for you...

-igor

On Sun, Feb 7, 2010 at 11:34 PM, Joachim Kainz <[email protected]> wrote:
> Wicket managing the id is not an option, as the generated id is tied
> to the session (and therefore not stateless).
>
> SetMarkupId on the other hand works great. Thank you! :)
>
> Sent from my iPhone
>
> On Feb 7, 2010, at 11:29 PM, Martijn Dashorst <[email protected]
>  > wrote:
>
>> just call setMarkupId("c2") or let wicket manage the ID.
>>
>> Martijn
>>
>> On Mon, Feb 8, 2010 at 6:51 AM, Joachim F. Kainz <[email protected]>
>> wrote:
>>> Igor,
>>>
>>> Thank you for responding back.
>>>
>>> Here is the code that I am using:
>>>
>>>        final Label c2 = new Label("c2", Integer.toString(counter));
>>>        final Link<?> c2Link = new
>>> StatelessAjaxFallbackLink<Void>("c2-link",
>>>                null, updatedParameters) {
>>>            private static final long serialVersionUID = 1L;
>>>
>>>           �...@override
>>>            public void onClick(final AjaxRequestTarget target) {
>>>                if (target != null) {
>>>                    target.addComponent(c2, "c2");
>>>                }
>>>            }
>>>        };
>>>
>>> Here is my HTML:
>>>
>>> <span wicket:id="c2" id="c2"></span>
>>> <a href="#" wicket:id="c2-link">increment</a>
>>>
>>> Instead of calling c2.setOutputMarkupId(true), I am passing the ID
>>> ("c2") to the component, which means that my
>>> StatelessAjaxFallbackLink
>>> works perfectly the first time around. The HTML that is generated for
>>> the C2 span unfortunately contains the wrong ID the second time
>>> around,
>>> because the Component#setOutputMarkupId(true) executed as part of
>>> AjaxRequestTarget#respondComponent(Response, String, Component)
>>> generates the wrong id.
>>>
>>> Without the call to Component#setOutputMarkupId(true) the id would
>>> just
>>> remain "c2" and my StatelessAjaxFallbackLink would work perfectly.
>>>
>>> BTW: The call to Component#setOutputMarkupId(true) is redundant
>>> anyway
>>> as AjaxRequestTarget#addComponent(Component) already enforces that
>>> the
>>> value must be true...
>>>
>>> Best regards,
>>>
>>> Joachim
>>>
>>> On Sun, 2010-02-07 at 20:18 -0800, Igor Vaynberg wrote:
>>>
>>>> Why remove it?
>>>>
>>>> -Igor
>>>>
>>>>
>>>> On Sunday, February 7, 2010, Joachim F. Kainz <[email protected]>
>>>> wrote:
>>>>> Dear Developers,
>>>>>
>>>>> I am working for a very, very, very large global retailer and we
>>>>> are
>>>>> about to roll out a very high-volume mobile application using
>>>>> Wicket.
>>>>>
>>>>> In order to support some of the requirements we have I have been
>>>>> working
>>>>> on adding a few more stateless components to Wicket. As one
>>>>> example, I
>>>>> added a StatelessAjaxFailbankLink. I also added a StatelessLink
>>>>> that
>>>>> works better for our app. The code is APL2 licensed and available
>>>>> at
>>>>> http://jolira-tools.googlecode.com/svn/wicket-stateless/trunk/
>>>>> together
>>>>> with  demo application.
>>>>>
>>>>> The demo works perfectly, when clicking on the link the first
>>>>> time. The
>>>>> second time it does not. The reason for this problem is that
>>>>> AjaxRequestTarget#respondComponent(Response, String, Component)
>>>>> method
>>>>> calls Component#setOutputMarkupId(boolean) with a value of true.
>>>>>
>>>>> I looked for quite a while but I have not found a way to override
>>>>> this
>>>>> behavior anywhere. I would greatly appreciate it, if somebody could
>>>>> suggest an approach or if somebody could suggest how to remove
>>>>> this line
>>>>> from the AjaxRequestTarget in a future version of the wicket code.
>>>>> Removing the line should be side-effect free as, in cases this
>>>>> line is
>>>>> actually used, this setting is verified earlier in the code.
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Joachim
>>>>>
>>>>>
>>>
>>
>>
>>
>> --
>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>> Apache Wicket 1.4 increases type safety for web applications
>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
>

Reply via email to