RE: Creating a Wicket Session outside of a Wicket request

2011-11-15 Thread David Berkman
Normally, wicket wraps HttpSession, which you can't get outside of an
HttpRequest. Shiro provides a session you can get from a pojo context.
If your code and wicket use the Shiro session, then you can hold the
same session both inside and outside the HttpRequest. Shiro will
remember your login if you want it to. You can get the session from
Shiro and manipulate it as a 'raw' Shiro session any way you need to.
Yes.

David

-Original Message-
From: Thomas Heigl [mailto:tho...@umschalt.com] 
Sent: Tuesday, November 15, 2011 12:27 PM
To: users@wicket.apache.org
Subject: Re: Creating a Wicket Session outside of a Wicket request

That looks quite straight forward, but wouldn't I still have the same
problem I'm currently facing? The ShiroWebSession is still just a normal
wicket session that can't be created from outside the Wicket request.

Or are you suggesting to login the subject using "raw" Shiro and then
check in the next wicket request if the subject is authenticated and log
him in transparently?

Thomas

On Tue, Nov 15, 2011 at 8:40 PM, David Berkman
wrote:

> Don't know. It was easy enough I just rolled my own.
>
> David
>
> -Original Message-
> From: anant.a...@gmail.com [mailto:anant.a...@gmail.com]
> Sent: Tuesday, November 15, 2011 11:36 AM
> To: users@wicket.apache.org
> Subject: Re: Creating a Wicket Session outside of a Wicket request
>
> That's interesting I was trying to do some thing similar n eariler and

> just dropped it. Is it possible to use wicket shiro instead?
> -Original Message-
> From: "David Berkman" 
> Date: Tue, 15 Nov 2011 11:09:10
> To: 
> Reply-To: users@wicket.apache.org
> Subject: RE: Creating a Wicket Session outside of a Wicket request
>
> You can integrate Shiro with auth-roles very easily. Just create 
> ShiroAuthenticatedWebSession.
>
> package com.wicketized.extension.security;
>
> import java.util.LinkedList;
> import org.apache.shiro.SecurityUtils; import 
> org.apache.shiro.authc.UsernamePasswordToken;
> import org.apache.shiro.subject.Subject; import 
> org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
> import 
> org.apache.wicket.authroles.authorization.strategies.role.Roles;
> import org.apache.wicket.request.Request;
>
> public class ShiroWebSession extends AuthenticatedWebSession {
>
>  private static final Roles NO_ROLES = new Roles();
>
>  public ShiroWebSession (Request request) {
>
>super(request);
>  }
>
>  @Override
>  public boolean authenticate (String username, String password) {
>
>Subject currentUser;
>
>if (!(currentUser = SecurityUtils.getSubject()).isAuthenticated()) 
> {
>
>  UsernamePasswordToken token = new UsernamePasswordToken(username,

> password);
>
>  token.setRememberMe(true);
>  try {
>currentUser.login(token);
>  }
>  catch (Exception exception) {
>
>return false;
>  }
>}
>
>return true;
>  }
>
>  @Override
>  public Roles getRoles () {
>
>Subject subject;
>
>if (((subject = SecurityUtils.getSubject()) != null) &&
> subject.isAuthenticated()) {
>
>  LinkedList codeList;
>  String[] codes;
>
>  codeList = new LinkedList();
>  for (RoleType roleType : RoleType.values()) {
>if (subject.hasRole(roleType.getCode())) {
>  codeList.add(roleType.getCode());
>}
>  }
>
>  codes = new String[codeList.size()];
>  codeList.toArray(codes);
>
>  return new Roles(codes);
>}
>
>return NO_ROLES;
>  }
>
>  @Override
>  public void signOut () {
>
>SecurityUtils.getSubject().logout();
>super.signOut();
>  }
> }
>
> -Original Message-
> From: Thomas Heigl [mailto:tho...@umschalt.com]
> Sent: Tuesday, November 15, 2011 11:06 AM
> To: users@wicket.apache.org
> Subject: Re: Creating a Wicket Session outside of a Wicket request
>
> Hey David,
>
> Thanks for your reply! I have thought about using Spring Security or 
> Shire, but at the moment the minimal wicket-auth-roles is enough for 
> my requirements. I'd prefer to just create the session myself when I 
> need it.
>
> Any other ideas?
>
> Cheers,
>
> THomas
>
> On Tue, Nov 15, 2011 at 8:02 PM, David Berkman
> wrote:
>
> > Apache Shiro, and create a shiro version of WebSession. Then wicket 
> > can ask for the Shio Session from the Http context, and you can get 
> > it
>
> > outside the context.
> >
> > David
> >
> > -Original Message-
> > From: Thomas Heigl [mailto:tho...@umschalt.com]
> > Sent: Tuesday, November 15, 2

RE: Creating a Wicket Session outside of a Wicket request

2011-11-15 Thread David Berkman
Don't know. It was easy enough I just rolled my own.

David

-Original Message-
From: anant.a...@gmail.com [mailto:anant.a...@gmail.com] 
Sent: Tuesday, November 15, 2011 11:36 AM
To: users@wicket.apache.org
Subject: Re: Creating a Wicket Session outside of a Wicket request

That's interesting I was trying to do some thing similar n eariler and
just dropped it. Is it possible to use wicket shiro instead?
-Original Message-----
From: "David Berkman" 
Date: Tue, 15 Nov 2011 11:09:10
To: 
Reply-To: users@wicket.apache.org
Subject: RE: Creating a Wicket Session outside of a Wicket request

You can integrate Shiro with auth-roles very easily. Just create
ShiroAuthenticatedWebSession.

package com.wicketized.extension.security;

import java.util.LinkedList;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject; import
org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
import org.apache.wicket.authroles.authorization.strategies.role.Roles;
import org.apache.wicket.request.Request;

public class ShiroWebSession extends AuthenticatedWebSession {

  private static final Roles NO_ROLES = new Roles();

  public ShiroWebSession (Request request) {

super(request);
  }

  @Override
  public boolean authenticate (String username, String password) {

Subject currentUser;

if (!(currentUser = SecurityUtils.getSubject()).isAuthenticated()) {

  UsernamePasswordToken token = new UsernamePasswordToken(username,
password);

  token.setRememberMe(true);
  try {
currentUser.login(token);
  }
  catch (Exception exception) {

return false;
  }
}

return true;
  }

  @Override
  public Roles getRoles () {

Subject subject;

if (((subject = SecurityUtils.getSubject()) != null) &&
subject.isAuthenticated()) {

  LinkedList codeList;
  String[] codes;

  codeList = new LinkedList();
  for (RoleType roleType : RoleType.values()) {
if (subject.hasRole(roleType.getCode())) {
  codeList.add(roleType.getCode());
}
  }

  codes = new String[codeList.size()];
  codeList.toArray(codes);

  return new Roles(codes);
}

return NO_ROLES;
  }

  @Override
  public void signOut () {

SecurityUtils.getSubject().logout();
super.signOut();
  }
}

-Original Message-
From: Thomas Heigl [mailto:tho...@umschalt.com]
Sent: Tuesday, November 15, 2011 11:06 AM
To: users@wicket.apache.org
Subject: Re: Creating a Wicket Session outside of a Wicket request

Hey David,

Thanks for your reply! I have thought about using Spring Security or
Shire, but at the moment the minimal wicket-auth-roles is enough for my
requirements. I'd prefer to just create the session myself when I need
it.

Any other ideas?

Cheers,

THomas

On Tue, Nov 15, 2011 at 8:02 PM, David Berkman
wrote:

> Apache Shiro, and create a shiro version of WebSession. Then wicket 
> can ask for the Shio Session from the Http context, and you can get it

> outside the context.
>
> David
>
> -Original Message-
> From: Thomas Heigl [mailto:tho...@umschalt.com]
> Sent: Tuesday, November 15, 2011 10:57 AM
> To: users@wicket.apache.org
> Subject: Creating a Wicket Session outside of a Wicket request
>
> Hey all,
>
> I have a requirement where I'd like to create a Wicket Session outside

> of a Wicket request:
>
> My application runs stand-alone (no problem here) and as a Facebook 
> application. Facebook calls my REST authentication service with a 
> user's credentials if they open my application in facebook. At this 
> point I don't have a Wicket session, but want to signin the user in my

> AuthenticatedWebSession from wicket-auth-roles. I'm using the 
> WicketSessionFilter in front of my REST service to get access to the 
> session, which works fine if the session already exists. If there is 
> no session, as in this case, the filter throws an
IllegalArgumentException.
>
> Since I have access to the Wicket Application I thought about calling 
> Application.get().newSession(), but this method only accepts Wicket's 
> WebRequest and WebResponse objects. Is it somehow possible to bind a 
> new session in a non-wicket request?
>
> Kind regards,
>
> Thomas
>
> -
> 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: Creating a Wicket Session outside of a Wicket request

2011-11-15 Thread David Berkman
You can integrate Shiro with auth-roles very easily. Just create
ShiroAuthenticatedWebSession.

package com.wicketized.extension.security;

import java.util.LinkedList;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import
org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
import org.apache.wicket.authroles.authorization.strategies.role.Roles;
import org.apache.wicket.request.Request;

public class ShiroWebSession extends AuthenticatedWebSession {

  private static final Roles NO_ROLES = new Roles();

  public ShiroWebSession (Request request) {

super(request);
  }

  @Override
  public boolean authenticate (String username, String password) {

Subject currentUser;

if (!(currentUser = SecurityUtils.getSubject()).isAuthenticated()) {

  UsernamePasswordToken token = new UsernamePasswordToken(username,
password);

  token.setRememberMe(true);
  try {
currentUser.login(token);
  }
  catch (Exception exception) {

return false;
  }
}

return true;
  }

  @Override
  public Roles getRoles () {

Subject subject;

if (((subject = SecurityUtils.getSubject()) != null) &&
subject.isAuthenticated()) {

  LinkedList codeList;
  String[] codes;

  codeList = new LinkedList();
  for (RoleType roleType : RoleType.values()) {
if (subject.hasRole(roleType.getCode())) {
  codeList.add(roleType.getCode());
}
  }

  codes = new String[codeList.size()];
  codeList.toArray(codes);

  return new Roles(codes);
}

return NO_ROLES;
  }

  @Override
  public void signOut () {

SecurityUtils.getSubject().logout();
super.signOut();
  }
}

-Original Message-
From: Thomas Heigl [mailto:tho...@umschalt.com] 
Sent: Tuesday, November 15, 2011 11:06 AM
To: users@wicket.apache.org
Subject: Re: Creating a Wicket Session outside of a Wicket request

Hey David,

Thanks for your reply! I have thought about using Spring Security or
Shire, but at the moment the minimal wicket-auth-roles is enough for my
requirements. I'd prefer to just create the session myself when I need
it.

Any other ideas?

Cheers,

THomas

On Tue, Nov 15, 2011 at 8:02 PM, David Berkman
wrote:

> Apache Shiro, and create a shiro version of WebSession. Then wicket 
> can ask for the Shio Session from the Http context, and you can get it

> outside the context.
>
> David
>
> -Original Message-
> From: Thomas Heigl [mailto:tho...@umschalt.com]
> Sent: Tuesday, November 15, 2011 10:57 AM
> To: users@wicket.apache.org
> Subject: Creating a Wicket Session outside of a Wicket request
>
> Hey all,
>
> I have a requirement where I'd like to create a Wicket Session outside

> of a Wicket request:
>
> My application runs stand-alone (no problem here) and as a Facebook 
> application. Facebook calls my REST authentication service with a 
> user's credentials if they open my application in facebook. At this 
> point I don't have a Wicket session, but want to signin the user in my

> AuthenticatedWebSession from wicket-auth-roles. I'm using the 
> WicketSessionFilter in front of my REST service to get access to the 
> session, which works fine if the session already exists. If there is 
> no session, as in this case, the filter throws an
IllegalArgumentException.
>
> Since I have access to the Wicket Application I thought about calling 
> Application.get().newSession(), but this method only accepts Wicket's 
> WebRequest and WebResponse objects. Is it somehow possible to bind a 
> new session in a non-wicket request?
>
> Kind regards,
>
> Thomas
>
> -
> 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: Creating a Wicket Session outside of a Wicket request

2011-11-15 Thread David Berkman
Apache Shiro, and create a shiro version of WebSession. Then wicket can
ask for the Shio Session from the Http context, and you can get it
outside the context.

David

-Original Message-
From: Thomas Heigl [mailto:tho...@umschalt.com] 
Sent: Tuesday, November 15, 2011 10:57 AM
To: users@wicket.apache.org
Subject: Creating a Wicket Session outside of a Wicket request

Hey all,

I have a requirement where I'd like to create a Wicket Session outside
of a Wicket request:

My application runs stand-alone (no problem here) and as a Facebook
application. Facebook calls my REST authentication service with a user's
credentials if they open my application in facebook. At this point I
don't have a Wicket session, but want to signin the user in my
AuthenticatedWebSession from wicket-auth-roles. I'm using the
WicketSessionFilter in front of my REST service to get access to the
session, which works fine if the session already exists. If there is no
session, as in this case, the filter throws an IllegalArgumentException.

Since I have access to the Wicket Application I thought about calling
Application.get().newSession(), but this method only accepts Wicket's
WebRequest and WebResponse objects. Is it somehow possible to bind a new
session in a non-wicket request?

Kind regards,

Thomas

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



RE: wicket-dojo wrappers (correction)

2011-11-10 Thread David Berkman
All help appreciated. You can either fork the project and submit back to it, 
or, if you have a GitHub account, I can add you as a collaborator.

David

-Original Message-
From: anant.a...@gmail.com [mailto:anant.a...@gmail.com] 
Sent: Thursday, November 10, 2011 11:53 AM
To: users@wicket.apache.org
Subject: Re: wicket-dojo wrappers (correction)

David,
I would love to help you manage/maintain this project if you need help.
-Original Message-
From: "David Berkman" 
Date: Thu, 10 Nov 2011 11:50:12
To: 
Reply-To: users@wicket.apache.org
Subject: RE: wicket-dojo wrappers (correction)

Sorry. I guess I can't get away with putting up the code and walking away. I've 
translated the code into a complete, and building (at least locally), maven 
project. Anyone interested can fork it from GitHub, alter the poms, and get it 
rolling. I've put it on a new namespace I've bought for the purpose, and 
changed the project name to match.

https://github.com/zenbones/Wicketized

David

-Original Message-
From: James Stewart [mailto:james.stewart...@gmail.com]
Sent: Thursday, November 10, 2011 7:33 AM
To: users@wicket.apache.org
Subject: Re: wicket-dojo wrappers (correction)

Hi David,

Would it be possible to put up the jar that contains or the java file: 
org.smallmind.nutsnbolts.util.DotNotationComparator? I get a compile error with 
this and I don't understand what it does in terms of dot notation.

Thanks,
James.

On 10/11/2011 3:15 AM, David Berkman wrote:
> Sorry for the repost, but this list doesn't take attachments I guess, 
> so I've upload the code at https://github.com/zenbones/WicketDojo
>
>
> I've had a number of requests, so I'll upload this bit of code here so people 
> can have a look. I know there's room for improvement in the code that exists, 
> and a ton that needs to be done. There's a wicket-dojo project on GitHub 
> https://github.com/vijaykiran/wicketstuff-dojo that's much cleaner, with many 
> more advanced integrations. However, that project lacked implemented wrappers 
> for Dojo Dijits, which is what I wanted most. The code there also seemed a 
> bit daunting, so I began a project to make wrappers I could understand, and 
> extend, and learn both Wicket and Dojo in the process. This is the results so 
> far. The few advantages it has over the GitHub code I've linked to are...
>
> 1) A bunch of useful Dijits wrapped in a way I hope is fairly clear and 
> extensible (it's getting better).
> 2) All the wrappers use fluent APIs
> 3) You can generally set a field, or your own model, interchangeably. For 
> instance, if you want to set a Title, you can usually setTitle(String title) 
> or setTitleModel(IModel  titleModel). Being able to control the model 
> is extremely useful.
> 4) You can generally set attributes in your HTML and these values will 
> initialize the fields/models in the wrappers on a non-Ajax render. Values can 
> then be dynamically altered from there via Ajax (as with user interaction).
> 5) Using setIntermediateChanges(true) will generally update the wrappers' 
> fields/models upon user interactions with the Dijit, via Ajax (you can also 
> add DojoAjaxUpdatingBehaviors to get your own callbacks). This extends to 
> things like stack container updating its models for selected child index and 
> id.
>
> There's still much to do. It's not the cleanest code yet. It doesn't handle 
> animations or fx or anything but presenting widgets. It's part of a larger 
> project so I haven't presented a real build, just the code. If people are 
> interested, I can cleave this off and provide a true maven build.
>
> David


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



RE: wicket-dojo wrappers (correction)

2011-11-10 Thread David Berkman
Sorry. I guess I can't get away with putting up the code and walking away. I've 
translated the code into a complete, and building (at least locally), maven 
project. Anyone interested can fork it from GitHub, alter the poms, and get it 
rolling. I've put it on a new namespace I've bought for the purpose, and 
changed the project name to match.

https://github.com/zenbones/Wicketized

David

-Original Message-
From: James Stewart [mailto:james.stewart...@gmail.com] 
Sent: Thursday, November 10, 2011 7:33 AM
To: users@wicket.apache.org
Subject: Re: wicket-dojo wrappers (correction)

Hi David,

Would it be possible to put up the jar that contains or the java file: 
org.smallmind.nutsnbolts.util.DotNotationComparator? I get a compile error with 
this and I don't understand what it does in terms of dot notation.

Thanks,
James.

On 10/11/2011 3:15 AM, David Berkman wrote:
> Sorry for the repost, but this list doesn't take attachments I guess, 
> so I've upload the code at https://github.com/zenbones/WicketDojo
>
>
> I've had a number of requests, so I'll upload this bit of code here so people 
> can have a look. I know there's room for improvement in the code that exists, 
> and a ton that needs to be done. There's a wicket-dojo project on GitHub 
> https://github.com/vijaykiran/wicketstuff-dojo that's much cleaner, with many 
> more advanced integrations. However, that project lacked implemented wrappers 
> for Dojo Dijits, which is what I wanted most. The code there also seemed a 
> bit daunting, so I began a project to make wrappers I could understand, and 
> extend, and learn both Wicket and Dojo in the process. This is the results so 
> far. The few advantages it has over the GitHub code I've linked to are...
>
> 1) A bunch of useful Dijits wrapped in a way I hope is fairly clear and 
> extensible (it's getting better).
> 2) All the wrappers use fluent APIs
> 3) You can generally set a field, or your own model, interchangeably. For 
> instance, if you want to set a Title, you can usually setTitle(String title) 
> or setTitleModel(IModel  titleModel). Being able to control the model 
> is extremely useful.
> 4) You can generally set attributes in your HTML and these values will 
> initialize the fields/models in the wrappers on a non-Ajax render. Values can 
> then be dynamically altered from there via Ajax (as with user interaction).
> 5) Using setIntermediateChanges(true) will generally update the wrappers' 
> fields/models upon user interactions with the Dijit, via Ajax (you can also 
> add DojoAjaxUpdatingBehaviors to get your own callbacks). This extends to 
> things like stack container updating its models for selected child index and 
> id.
>
> There's still much to do. It's not the cleanest code yet. It doesn't handle 
> animations or fx or anything but presenting widgets. It's part of a larger 
> project so I haven't presented a real build, just the code. If people are 
> interested, I can cleave this off and provide a true maven build.
>
> David


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



wicket-dojo wrappers (correction)

2011-11-09 Thread David Berkman
Sorry for the repost, but this list doesn't take attachments I guess, so I've 
upload the code at https://github.com/zenbones/WicketDojo


I've had a number of requests, so I'll upload this bit of code here so people 
can have a look. I know there's room for improvement in the code that exists, 
and a ton that needs to be done. There's a wicket-dojo project on GitHub 
https://github.com/vijaykiran/wicketstuff-dojo that's much cleaner, with many 
more advanced integrations. However, that project lacked implemented wrappers 
for Dojo Dijits, which is what I wanted most. The code there also seemed a bit 
daunting, so I began a project to make wrappers I could understand, and extend, 
and learn both Wicket and Dojo in the process. This is the results so far. The 
few advantages it has over the GitHub code I've linked to are...

1) A bunch of useful Dijits wrapped in a way I hope is fairly clear and 
extensible (it's getting better).
2) All the wrappers use fluent APIs
3) You can generally set a field, or your own model, interchangeably. For 
instance, if you want to set a Title, you can usually setTitle(String title) or 
setTitleModel(IModel titleModel). Being able to control the model is 
extremely useful.
4) You can generally set attributes in your HTML and these values will 
initialize the fields/models in the wrappers on a non-Ajax render. Values can 
then be dynamically altered from there via Ajax (as with user interaction).
5) Using setIntermediateChanges(true) will generally update the wrappers' 
fields/models upon user interactions with the Dijit, via Ajax (you can also add 
DojoAjaxUpdatingBehaviors to get your own callbacks). This extends to things 
like stack container updating its models for selected child index and id.

There's still much to do. It's not the cleanest code yet. It doesn't handle 
animations or fx or anything but presenting widgets. It's part of a larger 
project so I haven't presented a real build, just the code. If people are 
interested, I can cleave this off and provide a true maven build.

David


wicket-dojo wrappers

2011-11-09 Thread David Berkman
I've had a number of requests, so I'll upload this bit of code here so people 
can have a look. I know there's room for improvement in the code that exists, 
and a ton that needs to be done. There's a wicket-dojo project on GitHub 
https://github.com/vijaykiran/wicketstuff-dojo that's much cleaner, with many 
more advanced integrations. However, that project lacked implemented wrappers 
for Dojo Dijits, which is what I wanted most. The code there also seemed a bit 
daunting, so I began a project to make wrappers I could understand, and extend, 
and learn both Wicket and Dojo in the process. This is the results so far. The 
few advantages it has over the GitHub code I've linked to are...

1) A bunch of useful Dijits wrapped in a way I hope is fairly clear and 
extensible (it's getting better).
2) All the wrappers use fluent APIs
3) You can generally set a field, or your own model, interchangeably. For 
instance, if you want to set a Title, you can usually setTitle(String title) or 
setTitleModel(IModel titleModel). Being able to control the model is 
extremely useful.
4) You can generally set attributes in your HTML and these values will 
initialize the fields/models in the wrappers on a non-Ajax render. Values can 
then be dynamically altered from there via Ajax (as with user interaction).
5) Using setIntermediateChanges(true) will generally update the wrappers' 
fields/models upon user interactions with the Dijit, via Ajax (you can also add 
DojoAjaxUpdatingBehaviors to get your own callbacks). This extends to things 
like stack container updating its models for selected child index and id.

There's still much to do. It's not the cleanest code yet. It doesn't handle 
animations or fx or anything but presenting widgets. It's part of a larger 
project so I haven't presented a real build, just the code. If people are 
interested, I can cleave this off and provide a true maven build.

David

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

RE: Advice wanted about polished component set with Wicket

2011-11-08 Thread David Berkman
I've had excellent success wrapping most of Dojo with Wicket, and it
would not be hard to complete the rest. There's a wicket-dojo project
out there, but it didn't seem to be active, so I just started in on my
own. Dojo is a comprehensive, well laid out project (always had a good
concept of namespace and packaging, unlike most other javascript
frameworks), with decent documentation. Browsers have a tendency to fire
events in different orders, and when you start adding your own 'onxxx'
functions, you can get unexpected behavior. My first guess would be that
this is the cause of your problems in IE, as it seems to be particularly
random in this regard. Dojo has its own, extensive, event framework,
that corrects for these issues. If you want to look at my code, let me
know and I'll send it your way.

David

-Original Message-
From: James Stewart [mailto:james.stewart...@gmail.com] 
Sent: Tuesday, November 08, 2011 4:58 AM
To: users@wicket.apache.org
Subject: Advice wanted about polished component set with Wicket

Hi all,

We have been using Wicket for some time now with our home grown html &
some wicket components. However, there are some complaints that our
components and pages look a bit bland.

This has prompted us to look around at various alternatives. We tried
using plain jQuery with wicket and found some odd behaviour here and
there on Internet Explorer when using Ajax, which we never got to the
bottom of. If I remember correctly it was the calendar appearing on
first render which then disappeared and it would never reappear again.

This has lead us to reassess our component situation. Having looked at
the wiQuery demo site it doesn't fill me with confidence. Perhaps it is
just the demo site that does not work well and is not an indication of
the underlying library.

The next library we are considering is Visural Wicket. It looks
promising but it only seem to have one developer working on it.

Otherwise we would probably look to something like YUI of which I have
some experience but not with Wicket. It would take some investigating
though to establish if it would have similar problems that we
encountered with JQuery.

Any advice or real world experience will be appreciated.

Thanks,
James.

-
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: How to run a JavaScript function from Form Constructor in Wicket

2011-11-08 Thread David Berkman
Add a Behavior, mark the behavior temporary (setTemporary(true)), and
override the Behavior's renderHead (Component component, IHeaderResponse
response) method, and call response.renderJavascript(). If you want the
JS function to go off every time the component is rendered, don't mark
the behavior as temporary.

David

-Original Message-
From: eugenebalt [mailto:eugeneb...@yahoo.com] 
Sent: Tuesday, November 08, 2011 10:16 AM
To: users@wicket.apache.org
Subject: How to run a JavaScript function from Form Constructor in
Wicket

In my Form Constructor, I need to run a JS function. Is there any way to
do it?

Thanks

--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/How-to-run-a-JavaScript-funct
ion-from-Form-Constructor-in-Wicket-tp4016957p4016957.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


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



RE: wicket-4200 still broken in 1.5-SNAPSHOT

2011-11-07 Thread David Berkman
It's O.K., and you were correct. The wicket-ajax.js file have been cached, 
because clearing the cache got things working again with the SNAPSHOT.

Thanks,
David

-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] 
Sent: Sunday, November 06, 2011 9:21 PM
To: users@wicket.apache.org
Subject: Re: wicket-4200 still broken in 1.5-SNAPSHOT

maybe your browser has cached wicket-ajax.js? try clearing the browser cache. 
otherwise check if your browser sees the below lines in wicket-ajax.js which 
execute the prepending javascript:


// go through the ajax response and execute all priority-invocations 
first

for (var i = 0; i < root.childNodes.length; ++i) {
var node = root.childNodes[i];  
if (node.tagName == "priority-evaluate") {
   this.processEvaluation(steps, node);
}
}

// go through the ajax response and for every action 
(component, js evaluation, header contribution)


if the above is in your ajax js and it still doesnt work attach a quickstart to 
the jira ticket that reproduces your particular problem.

-igor


On Sun, Nov 6, 2011 at 6:41 PM, David Berkman  wrote:
> I understand that wicket-4200 (no prepended javascript in
> onBeforeRender()) is marked fixed in 1.5.3. I pulled the latest 
> SNAPSHOT to see if I could get an early fix. It may be that the 
> current snapshot is known to be unstable in this regard, but 
> prepending javascript still does not work. I've been told it does, but 
> it really does not and you may want to check this out. I added these lines to 
> an ajax target...
>
>
>
>      StringBuilder prependBuilder;
>
>      StringBuilder appendBuilder;
>
>
>
>      prependBuilder = new StringBuilder("var outerDijit =
> dijit.byId('").append(dojoComponent.getMarkupId()).append("');")
>
>        .append("if (outerDijit)
> {outerDijit.destroyDescendants();outerDijit.destroyRecursive();")
>
>
> .append("dojo.byId('").append(dojoComponent.getDijitContainerMarkupId(
> )) 
> .append("').id='").append(dojoComponent.getMarkupId()).append("'}");
>
>
>
>      appendBuilder = new
> StringBuilder("dojo.parser.parse(dojo.byId('").append(dojoComponent.ge
> tD ijitContainerMarkupId()).append("'));");
>
>
>
>      target.prependJavaScript("alert('boofaz');");
>
>      target.prependJavaScript(prependBuilder);
>
>      target.appendJavaScript(appendBuilder);
>
>
>
> Really, most of this code does not matter. Just note that the first 
> bit of javascript is the simple alert('boofaz') (why 'boofaz', why not?).
> The resulting return has this as the first priority-evaluate...
>
>
>
> 
>
>
>
> ...but no alert is ever produced. However, it's clear from the results 
> of the ajax return that the regular evaluate sections are run. So 
> something is wrong with the latest wicket-ajax.js.
>
>
>
> David
>
>

-
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



wicket-4200 still broken in 1.5-SNAPSHOT

2011-11-06 Thread David Berkman
I understand that wicket-4200 (no prepended javascript in
onBeforeRender()) is marked fixed in 1.5.3. I pulled the latest SNAPSHOT
to see if I could get an early fix. It may be that the current snapshot
is known to be unstable in this regard, but prepending javascript still
does not work. I've been told it does, but it really does not and you
may want to check this out. I added these lines to an ajax target...

 

  StringBuilder prependBuilder;

  StringBuilder appendBuilder;

 

  prependBuilder = new StringBuilder("var outerDijit =
dijit.byId('").append(dojoComponent.getMarkupId()).append("');")

.append("if (outerDijit)
{outerDijit.destroyDescendants();outerDijit.destroyRecursive();")

 
.append("dojo.byId('").append(dojoComponent.getDijitContainerMarkupId())
.append("').id='").append(dojoComponent.getMarkupId()).append("'}");

 

  appendBuilder = new
StringBuilder("dojo.parser.parse(dojo.byId('").append(dojoComponent.getD
ijitContainerMarkupId()).append("'));");

 

  target.prependJavaScript("alert('boofaz');");

  target.prependJavaScript(prependBuilder);

  target.appendJavaScript(appendBuilder);

 

Really, most of this code does not matter. Just note that the first bit
of javascript is the simple alert('boofaz') (why 'boofaz', why not?).
The resulting return has this as the first priority-evaluate...

 



 

...but no alert is ever produced. However, it's clear from the results
of the ajax return that the regular evaluate sections are run. So
something is wrong with the latest wicket-ajax.js.

 

David



RE: AjaxRequestTarget does not allow prepending javascript

2011-11-05 Thread David Berkman
OK. I pulled the latest Snapshot, which is also broken in its own way 
(prepended scripts are included as  but still don't get 
run). S, when is 1.5.3 due out, and is there a workaround, maybe via a 
Listener, that would substitute for now?

David

-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] 
Sent: Saturday, November 05, 2011 12:46 PM
To: users@wicket.apache.org
Subject: Re: AjaxRequestTarget does not allow prepending javascript

fixed. see wicket-4200

-igor

On Fri, Nov 4, 2011 at 10:59 PM, David Berkman  wrote:
> Not sure why, but, in 1.5.2 (at least), the call order is such that 
> prependJavascript is not called on AjaxRequestTarget until after
> constructResponseBody() has passed...
>
>
>
>                                Iterator it = 
> prependJavaScripts.iterator();
>
>                                while (it.hasNext())
>
>                                {
>
>                                                CharSequence js = 
> it.next();
>
>
> respondInvocation(bodyResponse, js);
>
>                                }
>
>
>
> ...assuring that no prepended scripts are attached to the ajax return.
> At least from onBeforeRender().
>
>
>
> I can freely add any appended script I want, but no prepended ones. 
> This strikes me as not good. Very bad.
>
>
>
> My code bits...
>
>
>
>  @Override
>
>  protected void onBeforeRender () {
>
>
>
>    if ((activeRequestHandler =
> getRequestCycle().getActiveRequestHandler()) instanceof
> AjaxRequestTarget) {
>
>      ((AjaxRequestTarget)activeRequestHandler). prependJavaScript 
> ("alert('never called')");
>
>      ((AjaxRequestTarget)activeRequestHandler). appendJavaScript 
> ("alert('always called')");
>
>    }
>
>  }
>
>
>
> David
>
>
>
>

-
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



AjaxRequestTarget does not allow prepending javascript

2011-11-04 Thread David Berkman
Not sure why, but, in 1.5.2 (at least), the call order is such that
prependJavascript is not called on AjaxRequestTarget until after
constructResponseBody() has passed...

 

Iterator it =
prependJavaScripts.iterator();

while (it.hasNext())

{

CharSequence js =
it.next();

 
respondInvocation(bodyResponse, js);

}

 

...assuring that no prepended scripts are attached to the ajax return.
At least from onBeforeRender().

 

I can freely add any appended script I want, but no prepended ones. This
strikes me as not good. Very bad.

 

My code bits...

 

  @Override

  protected void onBeforeRender () {

 

if ((activeRequestHandler =
getRequestCycle().getActiveRequestHandler()) instanceof
AjaxRequestTarget) {

  ((AjaxRequestTarget)activeRequestHandler). prependJavaScript
("alert('never called')");

  ((AjaxRequestTarget)activeRequestHandler). appendJavaScript
("alert('always called')");

}

  }

 

David

 



RE: Problem with Panel default model

2011-10-26 Thread David Berkman
It does...

  private static final ThreadLocal STRIP_TAGS_LOCAL = new 
ThreadLocal();

  @Override
  protected void onBeforeRender () {

super.onBeforeRender();


STRIP_TAGS_LOCAL.set(Application.get().getMarkupSettings().getStripWicketTags());
Application.get().getMarkupSettings().setStripWicketTags(true);
  }

  @Override
  protected void onAfterRender () {


Application.get().getMarkupSettings().setStripWicketTags(STRIP_TAGS_LOCAL.get());

super.onAfterRender();
  }

...using these methods to strip wicket tags for the rendering of this panel 
only. But, both onBeforeRender() and onAfterRender() are calling the same 
methods on their super class, which is Panel, and I'm not touching any models.

David 


-Original Message-
From: Andrea Del Bene [mailto:adelb...@ciseonweb.it] 
Sent: Wednesday, October 26, 2011 1:13 AM
To: users@wicket.apache.org
Subject: Re: Problem with Panel default model

Hi,

does your page override onBeforeRender method? Can you show the code?
> Thank you. Upgrade to 1.5.2 did seem to resolve the issue with the last ajax 
> request parameters being pushed onto the base url. However, testing that 
> resolution exposed a further problem. I'm using a 
> org.apache.wicket.markup.html.panel.Panel into which I'm handing the a 
> org.apache.wicket.model.Model and setting it as the default model via the 
> constructor...
>
>public class MyPanel extends Panel {
>
>  public MyPanel (final String id, final IModel<>  model) {
>
>super(id, model);
>  }
>}
>
>
> The model in question stores a java Enum, call it MyEnum...
>
>public enum MyEnum {
>
>  ONE, TWO, THREE
>}
>
>new MyPanel("panelId", new Model(MyEnum.values()[0]));
>
>
> On an ajax callback I update the model on this panel...
>
>public class MyPanel extends Panel {
>
>  ...
>
>  public void setValue (String value) {
>
>setDefaultModelObject(MyEnum.value(value));
>  }
>}
>
> ...all of which works fine. The problem is that the value which is set at the 
> time of the first page reload is the value that will be reset upon any 
> subsequent page reload. The model updates correctly on the MyPanel instance 
> responding to each ajax callback. Not a problem. But when I reload the page, 
> the value of the model will revert to whatever value it had after the *first* 
> page reload. I notice that the default model instance changes upon page 
> reload. So, for example...
>
> 1) MyPanel holds Model@1234
> 2) set Model@1234 to value MyEnum.TWO, no problem
> 3) page reload...
> 4) MyPanel now holds Model@2345 which holds MyEnum.TWO... this is correct, 
> but the Model instance has changed.
> 5) set Model@2345 to value MyEnum.THREE, no problem
> 6) page reload...
> 7) MyPanel now holds Model@3456 which holds MyEnum.TWO, where did MyEnum.TWO 
> come from?
> 8) I can now continue to set the model value via ajax callbacks, and all is 
> well, and the Model@3456 holds its values just fine
> 9) page reload...
> 10) No matter what the value of the Model@3456 was last set to, MyPanel now 
> holds new instance Model@4567 which *will* hold MyEnum.TWO
>
> Anyone know what's going on?
>
> Thank you,
> David
>
>
> -Original Message-
> From: Martin Grigorov [mailto:mgrigo...@apache.org]
> Sent: Monday, October 24, 2011 10:24 PM
> To: users@wicket.apache.org
> Subject: Re: Problem with ajax base url
>
> Hi
>
> Try with 1.5.2.
> This is fixed with https://issues.apache.org/jira/browse/WICKET-4109
>


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



RE: AbstractAutoCompleteRenderer.getOnSelectJavaScriptExpression doesn't have access for callbackUrl

2011-10-25 Thread David Berkman
How about...

  @Override
  public void renderHead (IHeaderResponse response) {

response.renderJavaScript("var foo='" + myBehavior.getCallbackUrl() +"';");
  }

...or just put the callback into whatever javascript requires it dynamically 
upon page construction via some similar methodology.

David

-Original Message-
From: Илья Нарыжный [mailto:phan...@ydn.ru] 
Sent: Tuesday, October 25, 2011 11:25 AM
To: users@wicket.apache.org
Subject: AbstractAutoCompleteRenderer.getOnSelectJavaScriptExpression doesn't 
have access for callbackUrl

Hello,

Is't possible to obtain callbackUrl in javascript rendered by
AbstractAutoCompleteRenderer.getOnSelectJavaScriptExpression?

We have following case: by autocomplete some of the already existing objects
can be selected, after that  will be disabled (because already
existing object was selected). Bit to implement this after selection of
partical row from the autocomplition list some callback code on the server
side should be invoked by "OnSelect". But there is no access to callbackUrl
within  AbstractAutoCompleteRenderer.getOnSelectJavaScriptExpression to be
able to create wicketAjaxGet request.

P.S. As workaround we can store callbackUrl within "domready" to be able to
"evaluate" url in onscript.
P.P.S. May be it's much more simple to make field 'renderer' in
AutoCompleteBehavior protected or add getter method? In that case
callbackUrl can be populated to custom renderer?

Ilia


Problem with Panel default model

2011-10-25 Thread David Berkman
Thank you. Upgrade to 1.5.2 did seem to resolve the issue with the last ajax 
request parameters being pushed onto the base url. However, testing that 
resolution exposed a further problem. I'm using a 
org.apache.wicket.markup.html.panel.Panel into which I'm handing the a 
org.apache.wicket.model.Model and setting it as the default model via the 
constructor...

  public class MyPanel extends Panel {

public MyPanel (final String id, final IModel<> model) {

  super(id, model);
}
  }


The model in question stores a java Enum, call it MyEnum...

  public enum MyEnum {

ONE, TWO, THREE
  }

  new MyPanel("panelId", new Model(MyEnum.values()[0]));


On an ajax callback I update the model on this panel...

  public class MyPanel extends Panel {

...

public void setValue (String value) {

  setDefaultModelObject(MyEnum.value(value));
}
  }

...all of which works fine. The problem is that the value which is set at the 
time of the first page reload is the value that will be reset upon any 
subsequent page reload. The model updates correctly on the MyPanel instance 
responding to each ajax callback. Not a problem. But when I reload the page, 
the value of the model will revert to whatever value it had after the *first* 
page reload. I notice that the default model instance changes upon page reload. 
So, for example...

1) MyPanel holds Model@1234
2) set Model@1234 to value MyEnum.TWO, no problem
3) page reload...
4) MyPanel now holds Model@2345 which holds MyEnum.TWO... this is correct, but 
the Model instance has changed.
5) set Model@2345 to value MyEnum.THREE, no problem
6) page reload...
7) MyPanel now holds Model@3456 which holds MyEnum.TWO, where did MyEnum.TWO 
come from?
8) I can now continue to set the model value via ajax callbacks, and all is 
well, and the Model@3456 holds its values just fine
9) page reload...
10) No matter what the value of the Model@3456 was last set to, MyPanel now 
holds new instance Model@4567 which *will* hold MyEnum.TWO

Anyone know what's going on?

Thank you,
David


-Original Message-
From: Martin Grigorov [mailto:mgrigo...@apache.org] 
Sent: Monday, October 24, 2011 10:24 PM
To: users@wicket.apache.org
Subject: Re: Problem with ajax base url

Hi

Try with 1.5.2.
This is fixed with https://issues.apache.org/jira/browse/WICKET-4109



Problem with ajax base url

2011-10-24 Thread David Berkman
I'm currently using wicket 1.5.1, testing with Firefox (latest).

 

When wicket receives an ajax GET request it seems to store the query
parameters of the last such request, and append them to the base url
upon page reload. I'm sure this behavior serves a very valid purpose,
but I'm wrapping a javascript-based component with a server side wicket
component, and the result is messing me up. To be specific, I have a
javascript select-like component which stores its current selection
choice in a value field, and I'm adding javascript via the renderHead()
method of the wicket wrapper to return that value via wicket ajax get.
I'm also sending whether this is an initial contact or a subsequent
selection. The render head method looks like...

 

  @Override

  public void renderHead (IHeaderResponse response) {

 

response.renderJavaScript("var " + getWatchFunctionName() + " =
function(){dijit.byId('" + select.getMarkupId() + "').watch('value',
function(name, oldValue, newValue){" +
valueChangedBehavior.getCallbackScript(false) +
"})};dojo.addOnLoad(function() {" +
valueChangedBehavior.getCallbackScript(true) + "});dojo.addOnLoad(" +
getWatchFunctionName() + ");", DojoSelect.class.getName() + ".watch." +
select.getMarkupId());

  }

 

As you can see it's a dojo select component, and I'm using dojo's
watch() function to call back to a behavior on the wicket wrapper...

 

  private class SelectValueChangedBehavior extends
AbstractDefaultAjaxBehavior {

 

private CharSequence getCallbackScript (boolean initial) {

 

  return generateCallbackScript("wicketAjaxGet('" +
getCallbackUrl(initial) + "'");

}

 

private CharSequence getCallbackUrl (boolean initial) {

 

  return super.getCallbackUrl() + "&" + select.getMarkupId() +
".value='+ dijit.byId('" + select.getMarkupId() + "').value + '&" +
select.getMarkupId() + ".initial=" + initial;

}

 

@Override

protected synchronized void respond (AjaxRequestTarget target) {

 

  boolean initial =
Boolean.parseBoolean(RequestCycle.get().getRequest().getQueryParameters(
).getParameterValue(select.getMarkupId() + ".initial").toString());

 

 
setValue(RequestCycle.get().getRequest().getQueryParameters().getParamet
erValue(select.getMarkupId() + ".value").toString(), initial);

 

  if (!initial) {

for (DojoAjaxUpdatingBehavior dojoAjaxUpdatingBehavior :
select.getBehaviors(DojoAjaxUpdatingBehavior.class)) {

  if (isNoOpEvent(dojoAjaxUpdatingBehavior.getEvent())) {

dojoAjaxUpdatingBehavior.onUpdate(target);

  }

}

  }

}

  }

 

All of which works just fine, and I'm happy with it. However, if the
select was the last ajax callback fired, and the page is reloaded, then
wicket adds
"&select.2.value=MY_SELECTION_CHOICE&select.2.initial=false", or
something similar, to the page url, and that then ends up in every
subsequent ajax request, which messes the works up terribly. I've tried
different methods of telling wicket not to add the last request
parameters to no avail. The page should not be reloaded, but if it is,
it's broken, and that bothers me. This behavior seems to be involved
with RequestCycle.get().getUrlRenderer().getBaseUrl(), and the code in
the default behavior...

 

Url baseUrl =
RequestCycle.get().getUrlRenderer().getBaseUrl();

CharSequence ajaxBaseUrl =
Strings.escapeMarkup(baseUrl.toString());

 
response.renderJavaScript("Wicket.Ajax.baseUrl=\"" + ajaxBaseUrl +
"\";",

"wicket-ajax-base-url");

 

I think it runs deeper than that however, because setting the base url
with...

 

   RequestCycle.get().getUrlRenderer().setBaseUrl(URL.pase(""));

 

...in onBeforeRender() or onAfterRender() hasn't stopped it. Maybe I
have the set in the wrong place? In any case, if anyone knows...

 

1)  Why wicket caches the query parameters and adds them to the base
url?

2)  How to stop wicket from doing?

 

...then I'd appreciate it.

 

Thanks in advance for any help,

 

David