Attach ajax/javascript to CheckBox, v1.4

2017-05-24 Thread sorinev
I have a version 7.x application where I have an Ajax component that I add
some javascript to via this method:

@Override
protected void updateAjaxAttributes(AjaxRequestAttributes
attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new AjaxCallListener()
.onBefore("$('#button1').prop('disabled',true);"
+ "$('#button2').prop('disabled',true);")
.onComplete("$('#button1').prop('disabled',false);"
+ "$('#button2').prop('disabled',false);"));
}

Now, I have a v1.4.17 app that I need to do the same thing to, but it's
going to be on a CheckBox (I could do AjaxCheckBox if necessary). I've tried
the various solutions I've googled, but to no avail. When the checkbox is
checked, some code runs. While that code runs, I need two buttons to be
disabled (doing it via the AjaxRequestTarget obviously won't work). When the
CheckBox's onUpdate code finishes running, the buttons can be enabled again.

This app is stuck on 1.4.17 for the foreseeable future and that's outside of
my hands.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Attach-ajax-javascript-to-CheckBox-v1-4-tp4677930.html
Sent from the Users forum 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



Re: Question about

2017-05-24 Thread Andrea Del Bene

Hi,

I think it's actually a bug. Could you open an issue on JIRA?

Andrea.

PS: thank you for investigating the issue!

On 24/05/2017 18:45, Claudia Hirt wrote:

Sorry, I think my description was a little unspecific.

The problem appears with the following HTML-code:





with autolinking set to true.

This leads to the following exception:
org.apache.wicket.markup.MarkupException: Unable to find component 
with id 'top' in [WebMarkupContainer [Component id = 
_autolink_-335431082]]

Expected: '_autolink_-335431082:top'.

WICKET-6289 doesn't really break it, there's nothing wrong with it. 
But the bugfix in this issue was to create an autocomponent which is a 
WebMarkupContainer. I think it was some kind of link before, which 
didn't cause any trouble.
But is it really correct that AutoLinkResolver even tries to replace 
an anchor link?


I also created a quickstart project to reproduce the problem:
https://github.com/sunshineKE/test.autolinking

Best regards, Claudia


Am 23.05.2017 um 22:31 schrieb Martin Grigorov:

Hi,

It is not very clear how your code looks like.
Could you please provide more information the setup and how WICKET-6289
breaks it ?
A quickstart application would be the best way to show us! You can 
share it

via GitHub/BitBucket or even attach it to a ticket in JIRA!
Thank you!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, May 23, 2017 at 9:47 PM, Claudia Hirt  
wrote:



Hi all,

there's something I came across when trying to migrate an 
application to

Wicket 7.7.
When using an anchor link like  with autmatic linking
activated (getMarkupSettings().setAutomaticLinking(true)) the
AutolinkResolver breaks my hierarchy. This does not appear when
encapsulating the  tag inside a  Tag.
I saw that this appears since Bugfix from 
https://issues.apache.org/jira

/browse/WICKET-6289 was implemented.

Do I really have to use  for this kind of anchors or is 
it a

Bug?

Best regards,
Claudia



-
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: Questions regarding Wicket 8 and lambda expressions for models

2017-05-24 Thread Sven Meier

Hi,


WDYT ? Do we need to implement #detach() in #map(), #filter(), etc ?


yes, I think this is a good idea: the returned model holds a reference 
to the given model, so it should detach it.


Regards
Sven

On 24.05.2017 21:36, Martin Grigorov wrote:

On Tue, May 23, 2017 at 11:17 PM, Martin Grigorov 
wrote:


Hi,

On Tue, May 23, 2017 at 5:40 PM, Ihmehlmenn  wrote:


Hello everyone,

while trying out some of the very cool new features in Wicket 8,
specifically replacing PropertyModels with lambda expressions, I had a few
questions coming up. Most of them have been answered by the great guide
provided, but following things are still a bit unclear to me:


Thank you for testing the milestone release and for the feedback!



1) Read-Only Models
Let's say I want to replace the following PropertyModel for showing the
"name" property of a Person obejct in a Label

   new PropertyModel(personModel, "name");

with a lambda expression. Which of the following would be the best
approach
and why?

   LambdaModel.of(personModel, Person::getName);


This way of using LambdaModel is indeed the same as the second way. The
advantage LambdaModel has is that you can also set a value when you use the
method with the Supplier.



   personModel.map(Person::getName);
   personModel.flatMap(...); // not quite sure yet when to use this one.
See
next question as well



The first two options seem to be identical at the first glance but I
noticed
that the LambdaModel does call detach() on the underlying base model (just
like the PropertyModel does), whereas the model created by the map()
method
doesn't seem to do that.


This is a good point!
I think it is a bug that should be fixed!


Actually here we use closure so adding #detach() is not possible unless the
body is rewritten to instantiate an IModel with #getObject() and #detach()
impls.
I am not sure it is worth it.
@Devs WDYT ? Do we need to implement #detach() in #map(), #filter(), etc ?






2) Readable/Writeable Models
The documentation has the following example for mapping a model to a
readable/writeable model of a property

   IModel personNameModel = personModel.flatMap(targetPerson ->
   LambdaModel.of(
 () -> targetPerson::getName, targetPerson::setName
   ));

Why is the call to flatMap() needed? Isn't just using the LambdaModel the
same but shorter?

   IModel personNameModel = LambdaModel.of(personModel,
Person::getName, Person::setName);


IModel#flatMap() is like java.util.Optional#flatMap().
It is useful when you already have another IModel impl that knows how to
set/get the name of a person.
LambdaModel#of(IModel, SerializableFunction,
SerializableBiConsumer) is an easy way to create such IModel impl by
using Java 8 lambdas.
We should cross-reference them in the javadoc!

Another discussion on this topic: http://markmail.org/
message/m6l2w3ryqbdew2co




3) Constants in Models
In some cases I need to set a static constant value as read only model in
a
component. Up until now I simply used
Model.of(Constants.MY_STATIC_VALUE);
which probably results in the value being serialised into the session of
the
user.


The model and its content are serialized with the page.
The page is stored in the http session only after being rendered. Once you
move to another stateful page it is replaced by it and from there on it is
stored only on the disk.



Am I assuming correctly, that using following lambda expression as model
is
more "efficient", since the static constant isn't serialised anymore this
way?
   () -> Constants.MY_STATIC_VALUE;


Correct!
The static constant won't be serialized but the closure will be.
So this version should be close memory-wise to using AbstractReadOnlyModel
for this use case but anonymous inner classes have a reference to the outer
instance and afaik lambdas don't have it.




Thanks to everybody pouring so much time into developing Wicket!

Daniel Radünz

--
View this message in context: http://apache-wicket.1842946.n
4.nabble.com/Questions-regarding-Wicket-8-and-lambda-express
ions-for-models-tp4677918.html
Sent from the Users forum 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






Re: Questions regarding Wicket 8 and lambda expressions for models

2017-05-24 Thread Martin Grigorov
On Tue, May 23, 2017 at 11:17 PM, Martin Grigorov 
wrote:

> Hi,
>
> On Tue, May 23, 2017 at 5:40 PM, Ihmehlmenn  wrote:
>
>> Hello everyone,
>>
>> while trying out some of the very cool new features in Wicket 8,
>> specifically replacing PropertyModels with lambda expressions, I had a few
>> questions coming up. Most of them have been answered by the great guide
>> provided, but following things are still a bit unclear to me:
>>
>
> Thank you for testing the milestone release and for the feedback!
>
>
>>
>> 1) Read-Only Models
>> Let's say I want to replace the following PropertyModel for showing the
>> "name" property of a Person obejct in a Label
>>
>>   new PropertyModel(personModel, "name");
>>
>> with a lambda expression. Which of the following would be the best
>> approach
>> and why?
>>
>>   LambdaModel.of(personModel, Person::getName);
>>
>
> This way of using LambdaModel is indeed the same as the second way. The
> advantage LambdaModel has is that you can also set a value when you use the
> method with the Supplier.
>
>
>>   personModel.map(Person::getName);
>>   personModel.flatMap(...); // not quite sure yet when to use this one.
>> See
>> next question as well
>
>
>> The first two options seem to be identical at the first glance but I
>> noticed
>> that the LambdaModel does call detach() on the underlying base model (just
>> like the PropertyModel does), whereas the model created by the map()
>> method
>> doesn't seem to do that.
>>
>
> This is a good point!
> I think it is a bug that should be fixed!
>

Actually here we use closure so adding #detach() is not possible unless the
body is rewritten to instantiate an IModel with #getObject() and #detach()
impls.
I am not sure it is worth it.
@Devs WDYT ? Do we need to implement #detach() in #map(), #filter(), etc ?


>
>
>>
>>
>> 2) Readable/Writeable Models
>> The documentation has the following example for mapping a model to a
>> readable/writeable model of a property
>>
>>   IModel personNameModel = personModel.flatMap(targetPerson ->
>>   LambdaModel.of(
>> () -> targetPerson::getName, targetPerson::setName
>>   ));
>>
>> Why is the call to flatMap() needed? Isn't just using the LambdaModel the
>> same but shorter?
>>
>>   IModel personNameModel = LambdaModel.of(personModel,
>> Person::getName, Person::setName);
>>
>
> IModel#flatMap() is like java.util.Optional#flatMap().
> It is useful when you already have another IModel impl that knows how to
> set/get the name of a person.
> LambdaModel#of(IModel, SerializableFunction,
> SerializableBiConsumer) is an easy way to create such IModel impl by
> using Java 8 lambdas.
> We should cross-reference them in the javadoc!
>
> Another discussion on this topic: http://markmail.org/
> message/m6l2w3ryqbdew2co
>
>
>>
>>
>> 3) Constants in Models
>> In some cases I need to set a static constant value as read only model in
>> a
>> component. Up until now I simply used
>>Model.of(Constants.MY_STATIC_VALUE);
>> which probably results in the value being serialised into the session of
>> the
>> user.
>>
>
> The model and its content are serialized with the page.
> The page is stored in the http session only after being rendered. Once you
> move to another stateful page it is replaced by it and from there on it is
> stored only on the disk.
>
>
>>
>> Am I assuming correctly, that using following lambda expression as model
>> is
>> more "efficient", since the static constant isn't serialised anymore this
>> way?
>>   () -> Constants.MY_STATIC_VALUE;
>>
>
> Correct!
> The static constant won't be serialized but the closure will be.
> So this version should be close memory-wise to using AbstractReadOnlyModel
> for this use case but anonymous inner classes have a reference to the outer
> instance and afaik lambdas don't have it.
>
>
>>
>>
>> Thanks to everybody pouring so much time into developing Wicket!
>>
>> Daniel Radünz
>>
>> --
>> View this message in context: http://apache-wicket.1842946.n
>> 4.nabble.com/Questions-regarding-Wicket-8-and-lambda-express
>> ions-for-models-tp4677918.html
>> Sent from the Users forum 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
>>
>>
>


Re: Websocket redirect wrong url

2017-05-24 Thread Martin Grigorov
On Wed, May 24, 2017 at 12:18 PM, Peter Henderson <
peter.hender...@starjar.com> wrote:

> On 24 May 2017 at 11:05, Peter Henderson 
> wrote:
>
> >
> >
> > On 23 May 2017 at 22:24, Martin Grigorov  wrote:
> >
> >> Hi,
> >>
> >> I'm afraid a quickstart would be needed to be able to tell what goes
> wrong
> >> there.
> >>
> >
> > Thanks for looking, I thought you'd say that.
> > Attached is a quick (ish) start.
> >
> > browse to
> > https://localhost:/redirect/protected/path/pageA/112233
> > Press the button *boom*
> >
> > Removing the WebSocketBehavior on  BasePage makes the page work
> > (Although in a real app I need this behavior)
> >
> > Would it be helpful if I created this on github?
> >
>
>
>
>
> Sorry for the noise.
>
> I've just tried this on Wicket 7.7 and it seems to be fixed already.
> WICKET-6342
>

Sorry for the breakage!
That was indeed a silly mistake!


>
> I don't know what's more embarrassing. Posting a dumb bug report or
> spending days trying to narrow down the bug.
> Now to upgrade my main app *fingers crossed*
>
>
> --
> Peter Henderson
>


Re: Question about

2017-05-24 Thread Claudia Hirt

Sorry, I think my description was a little unspecific.

The problem appears with the following HTML-code:





with autolinking set to true.

This leads to the following exception:
org.apache.wicket.markup.MarkupException: Unable to find component with 
id 'top' in [WebMarkupContainer [Component id = _autolink_-335431082]]

Expected: '_autolink_-335431082:top'.

WICKET-6289 doesn't really break it, there's nothing wrong with it. But 
the bugfix in this issue was to create an autocomponent which is a 
WebMarkupContainer. I think it was some kind of link before, which 
didn't cause any trouble.
But is it really correct that AutoLinkResolver even tries to replace an 
anchor link?


I also created a quickstart project to reproduce the problem:
https://github.com/sunshineKE/test.autolinking

Best regards, Claudia


Am 23.05.2017 um 22:31 schrieb Martin Grigorov:

Hi,

It is not very clear how your code looks like.
Could you please provide more information the setup and how WICKET-6289
breaks it ?
A quickstart application would be the best way to show us! You can share it
via GitHub/BitBucket or even attach it to a ticket in JIRA!
Thank you!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, May 23, 2017 at 9:47 PM, Claudia Hirt  wrote:


Hi all,

there's something I came across when trying to migrate an application to
Wicket 7.7.
When using an anchor link like  with autmatic linking
activated (getMarkupSettings().setAutomaticLinking(true)) the
AutolinkResolver breaks my hierarchy. This does not appear when
encapsulating the  tag inside a  Tag.
I saw that this appears since Bugfix from https://issues.apache.org/jira
/browse/WICKET-6289 was implemented.

Do I really have to use  for this kind of anchors or is it a
Bug?

Best regards,
Claudia



-
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: Websocket redirect wrong url

2017-05-24 Thread Peter Henderson
On 24 May 2017 at 11:05, Peter Henderson 
wrote:

>
>
> On 23 May 2017 at 22:24, Martin Grigorov  wrote:
>
>> Hi,
>>
>> I'm afraid a quickstart would be needed to be able to tell what goes wrong
>> there.
>>
>
> Thanks for looking, I thought you'd say that.
> Attached is a quick (ish) start.
>
> browse to
> https://localhost:/redirect/protected/path/pageA/112233
> Press the button *boom*
>
> Removing the WebSocketBehavior on  BasePage makes the page work
> (Although in a real app I need this behavior)
>
> Would it be helpful if I created this on github?
>




Sorry for the noise.

I've just tried this on Wicket 7.7 and it seems to be fixed already.
WICKET-6342

I don't know what's more embarrassing. Posting a dumb bug report or
spending days trying to narrow down the bug.
Now to upgrade my main app *fingers crossed*


-- 
Peter Henderson


Re: Websocket redirect wrong url

2017-05-24 Thread Peter Henderson
On 23 May 2017 at 22:24, Martin Grigorov  wrote:

> Hi,
>
> I'm afraid a quickstart would be needed to be able to tell what goes wrong
> there.
>

Thanks for looking, I thought you'd say that.
Attached is a quick (ish) start.

browse to
https://localhost:/redirect/protected/path/pageA/112233
Press the button *boom*

Removing the WebSocketBehavior on  BasePage makes the page work
(Although in a real app I need this behavior)

Would it be helpful if I created this on github?


>
> The appearance of /wicket/ in the url looks like either BookmarkableMapper
> (responsible for urls like /wicket/bookmarkable/com.example.Page) or
> PageInstanceMapper (responsible for urls like /wicket/page?123) is used
> instead of MountedMapper (used when the page path is configured with
> WebApplication#mountPage(String, Class) method).
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Tue, May 23, 2017 at 2:46 PM, Peter Henderson <
> peter.hender...@starjar.com> wrote:
>
> > Hi all.
> >
> >
> > I'm seeing a strange redirect problem which leads to a 404
> >
> >
> > Scenario.
> > 1) User is on fat bookmarkable page [1]
> > 2) Ajax onClick redirects to non bookmarkable SendMessagePage
> > 3) SendMessage page uses websockets + background threads.
> > 4) SendMessage page receives a websocket push event which it responds to
> > with [2] or [3]
> >
> > When redirecting back to a really simple DummyPage all is fine.
> > When redirecting back to the fat bookmarkable page I get a 404 on url
> > https://local.starjar.com:25000/Starjar/protected/wicket/35883
> >
> > Both DummyPage and PurchaseOrderPage are mounted the same way.
> >
> >
> >
> > What am I doing which is causing the incorrect redirect path?
> >
> >
> > I'm (still) trying to build a quick start that reproduces this problem.
> >
> >
> > Further testing.
> >
> > I created a new class called Dummy2 which is identical to
> > PurchaseOrderPage. Just a different name and mount point.
> > Redirecting to Dummy2 works fine .
> >
> > It looks like Dummy2 => Dummy2 and PurchaseOrderPage => PurchaseOrderPage
> > both fail with the incorrect relative url.
> >
> >
> >
> >
> > Many thanks
> >
> > Peter.
> >
> >
> >
> >
> >
> > [1]
> > https://local.starjar.com:25000/Starjar/protected/purchaseOrder/35883
> >
> > [2]
> > // This works as expected
> > // https://local.starjar.com:25000/Starjar/protected/dummy/12334
> > val pageCls = classOf[DummyDetailPage]
> > val pp = new PageParameters()
> > pp.set(WicketStarjarApplication.DetailPageIdParameterName, 12334)
> > throw new RestartResponseException(pageCls, pp)
> >
> >
> > [3]
> > // This does not work 404
> > // https://local.starjar.com:25000/Starjar/protected/wicket/35883
> > val pageCls = classOf[PurchaseOrderDetailPage]
> > val pp = new PageParameters()
> > pp.set(WicketStarjarApplication.DetailPageIdParameterName,
> businessId.pk)
> > throw new RestartResponseException(pageCls, pp)
> >
> >
> >
> > --
> > Peter Henderson
> >
>



-- 
Peter Henderson

Director
Starjar Ltd.
www.starjar.com
0330 088 1662


redirect.tar.gz
Description: GNU Zip compressed data

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