SV: Localizer in a new Thread

2010-07-30 Thread Wilhelmsen Tor Iver
 To clarify, I want to use Localizer#getString(...) in a thraed I
 create.
 I have seen other posts on this issue, but haven't been able to figure
 out the solution.

The Localizer.getString() looks for its messages in Wicket's property file 
structure, which depends on Application, the resource-oriented classes, 
hierarchies and so forth. Your best bet is to pre-read the values you need 
into a Properties object that you pass to the thread code.

- Tor Iver

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



Re: FormComponentPanel Behavior

2010-07-30 Thread loic

Hello Bernard,
why did you ask a new question in this topic?

I think my issue is lost now :)

Dos anybody have an idea for the original question?

Thanks

Loic
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/WicketTester-and-Palette-component-tp2306743p2307708.html
Sent from the Wicket - User 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: Localizer in a new Thread

2010-07-30 Thread Alex Objelean

There was a long discussion about this. One of the proposal was to use
InheritableThreadLocal which would solve this problem, but there was a lot
of concerns about this approach. 

The solution I have found was this:
If you create the thread with ExecutorService, you could do the following:

final ExecutorService service = new ScheduledThreadPoolExecutor(1) {
  @Override
  protected void beforeExecute(final Thread t, final Runnable r) {
Application.set(app);
  };
  @Override
  protected void afterExecute(final Runnable r, final Throwable t) {
Application.unset();
  }
};

and execute you thread like this:
service.submit(new Runnable() {
@Override
public void run() {
  //do stuff
}
  });

This will ensure that Application is accessible from within newly created
thread.

Alex
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html
Sent from the Wicket - User 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



How to Update contents of a child component?

2010-07-30 Thread Niv

Hi All

I would like to know an elegant solution to deal with the following issue.

For CRUD operations this is the approach I have taken.

List of Components
1.ContainerPanel 
2.SearchPanel
3.SearchResultsPanel
4.DetailsPanel and this contains a child component that has a
MultiSelectControl

The ContainerPanel adds the SearchPanel. The SearchPanel, adds
SearchResultsPanel and DetailsPanel.

So when I first load/render the ContainerPanel, I hide the
SearchResultsPanel and DetailsPanel.
When some search is done then I make the SearchResultsPanel visible.

OnClick event of an item of the SearchResultsPanel , I unhide and update the
Model of the Details panel. Now,for some reason it does not seem to refresh
the child component in DetailsPanel(.ie. MultiSelectControl)

So on every OnClick, I want the Details panel to refresh the content of the
nested component in Details Panel. At the moment, I can't see a way to do
this, other than removing the nested component and re-creating it.  I am
sure its not the right way to do it.

Has anyone had a similar scenario before? I would like to use a cleaner way
to approach this.

Also is this approach for CRUD acceptable as in using the container
approach?
Thanks again,



-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-Update-contents-of-a-child-component-tp2307756p2307756.html
Sent from the Wicket - User 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: FormComponentPanel Behavior

2010-07-30 Thread bht
Yes I did. Is it better not to not do this?

Regards,

Bernard

On Thu, 29 Jul 2010 16:54:28 -0300, you wrote:

Hi Bernard, did you call setRequired method on your FormComponentPanel input
components?
like: formComponentPanel.fieldOne.setRequired(true)

On Thu, Jul 29, 2010 at 4:33 PM, b...@actrix.gen.nz wrote:

 Hi,

 org.apache.wicket.markup.html.form.FormComponentPanel
 aims to act to the outside world as one component.

 I want it to behave in a way that it flags missing required input on
 behalf of its enclosed components.

 Imagine an input component with 4 fields for a credit card number.

 If input in any of the fields is missing, then I want to highlight (eg
 with FormComponentFeedbackBorder) the enclosing component not any
 individual sub-fields .

 As an easy test example, please consider

 org.apache.wicket.examples.forminput.Multiply which is included in the
 Wicket distribution.


 http://www.wicketstuff.org/wicket/forminput/?wicket:bookmarkablePage=sources:org.apache.wicket.examples.source.SourcesPageSourcesPage_class=org.apache.wicket.examples.forminput.FormInputsource=Multiply.java

 What is the best way to change this example so that a Required error
 is generated for Multiply if any of its components are empty? I found
 that checkRequired() is not called.

 Many thanks.

 Bernard


 -
 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 Update contents of a child component?

2010-07-30 Thread bht
Hi,

Have you checked that rendered values in your components are
model-driven? If so then I think it should work. I sometimes set
values in the constructor with brute force when I do not expect any
changes. This is not what you want in this case.

I found it most helpful to exclusively use LoadableDetachableModel,
remove the Serializable interface from my model objects and let
SerializableChecker sort out some model problems for me. I went so far
as to use a LDM in my WebSession. After some time I had sufficient
practice with models that things started to become really easy.

Regards,

Bernard


On Fri, 30 Jul 2010 02:17:01 -0700 (PDT), you wrote:


Hi All

I would like to know an elegant solution to deal with the following issue.

For CRUD operations this is the approach I have taken.

List of Components
1.ContainerPanel 
2.SearchPanel
3.SearchResultsPanel
4.DetailsPanel and this contains a child component that has a
MultiSelectControl

The ContainerPanel adds the SearchPanel. The SearchPanel, adds
SearchResultsPanel and DetailsPanel.

So when I first load/render the ContainerPanel, I hide the
SearchResultsPanel and DetailsPanel.
When some search is done then I make the SearchResultsPanel visible.

OnClick event of an item of the SearchResultsPanel , I unhide and update the
Model of the Details panel. Now,for some reason it does not seem to refresh
the child component in DetailsPanel(.ie. MultiSelectControl)

So on every OnClick, I want the Details panel to refresh the content of the
nested component in Details Panel. At the moment, I can't see a way to do
this, other than removing the nested component and re-creating it.  I am
sure its not the right way to do it.

Has anyone had a similar scenario before? I would like to use a cleaner way
to approach this.

Also is this approach for CRUD acceptable as in using the container
approach?
Thanks again,


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



Re: How to Update contents of a child component?

2010-07-30 Thread vov

Do not forgot about setOutputMarkupPlaceholderTag(true) for your components
that initially as invisible.
And use AJAX...:)
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-Update-contents-of-a-child-component-tp2307756p2307883.html
Sent from the Wicket - User 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: Single session per user

2010-07-30 Thread jcgarciam

For that you may need to do your own session tracking using an
HttpSessionListenerhttp://download-llnw.oracle.com/javaee/5/api/javax/servlet/http/HttpSessionListener.html,
and trying to  handle yourself a Session cache (Be carefully of not leaking
those session by not preventing the container to reclaim that memory when
needed if they got stale).

Also i believe Spring Security (former Acegi) has builtin support for this
use case.

On Thu, Jul 29, 2010 at 5:56 AM, MelmanRo [via Apache Wicket] 
ml-node+2306158-2052172248-229...@n4.nabble.comml-node%2b2306158-2052172248-229...@n4.nabble.com
 wrote:

 Hi guys,

 I'm trying to achieve the behavior where if a user is logged in and he is
 logging in from some place else again, he would be logged out and prompted
 the login page in the first place.

 For now, I've experimented with Session#invalidateNow and
 ApplicationSettings#setExpiredErrorPage on the current session and it works
 fine. I can't figure out how I can invalidateNow other session than the
 current one. Besides this, a method that wouldn't require storing the
 sessionId for one user in the DB would be preferred (a Map at WebApplication
 level maybe?).

 Any suggestions are welcome. I've searched the forum for similar threads
 but didn't quite understand how to do it...

 Thanks

 --
  View message @
 http://apache-wicket.1842946.n4.nabble.com/Single-session-per-user-tp2306158p2306158.html
 To unsubscribe from Apache Wicket, click 
 herehttp://apache-wicket.1842946.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDExOTE5MDc4OTQ=.





-- 
Sincerely,
JC

Work smarter, not harder!.

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Single-session-per-user-tp2306158p2308007.html
Sent from the Wicket - User mailing list archive at Nabble.com.


Trouble creating a behaviour that adds JS and also a Body onLoad event

2010-07-30 Thread Mark Doyle
Firstly, I'm having some trouble finding a decent behaviour tutorial.  If
anybody knows of one post a link up.

Now, the problem I am having is creating a behaviour that adds some JS to
the head and sets an onLoad method.  The JS project instructs users to add:

body onload=jsfunctionhere ( options, callback );

but I'm not sure how Wicket supports this.

Any ideas?

Cheers


Re: Trouble creating a behaviour that adds JS and also a Body onLoad event

2010-07-30 Thread Martin Makundi
Hi!

You could try this:

public class HomePage extends WebPage implements IHeaderContributor {
  @Override
  public void renderHead(IHeaderResponse response) {
response.renderOnLoadJavascript(javascript)
  }


**
Martin

2010/7/30 Mark Doyle markjohndo...@googlemail.com:
 Firstly, I'm having some trouble finding a decent behaviour tutorial.  If
 anybody knows of one post a link up.

 Now, the problem I am having is creating a behaviour that adds some JS to
 the head and sets an onLoad method.  The JS project instructs users to add:

 body onload=jsfunctionhere ( options, callback );

 but I'm not sure how Wicket supports this.

 Any ideas?

 Cheers


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



Interesting Contract Full-time Positions

2010-07-30 Thread Randy Dean
I hope this is an acceptable use of the users email, if not I apologize.

 

I have  4 opportunities for contract or contract to hire Java/JEE developers
with solid Wicket experience.  This is with a very fast growing software
firm  with excellent management and very technically capable leadership.

 

These are heads down developer type roles and this organization is truly a
software development/engineering environment.  They are all about writing
good code, not any office politics or other big company type overhead.

 

These positions are in Columbus, OH.  If you have an interest, please let me
know.

 

Thanks,

Randy

 

 

 

Randy Dean
Fast Switch
37 W. Bridge St., Suite 200
Dublin, OH 43017
http://www.fastswitch.com/

*   rd...@fastswitch.com (best way to get in touch) 
*   614-309-8558  Cell (best way to catch me live- I respond fast to
texts) 
*   614-336-3634 Office(sometimes hard to catch me here)
*   614-336-3695 Fax (are faxes retro cool yet?) 

*http://twitter.com/guykawasaki http:// www.twitter.com/fastswitch
(for fastest awareness of our new positions) 
*   http://www.facebook.com/pages/Fast-Switch-Ltd/158158450221
*http://www.linkedin.com/in/randykdean
http://www.linkedin.com/in/randykdean

 



RE: Localizer in a new Thread

2010-07-30 Thread Warren Bell
I am not sure how to preload the the values. I am trying this, but am
not getting anywhere.

myApp.getResourceSettings().getPropertiesFactory().load(ScanManTask.clas
s, com.scanman.cron.task)

I have a properties file named ScanManTask.properties and have added it
to my app like this:

getResourceSettings().addStringResourceLoader(new
ClassStringResourceLoader(ScanManTask.class));

ScanManTask is not a commponent. The load method has a clazz and path
argument. I am assummeing the class is the class associated with the
property file and the path is the package it is in?

I guess I could just load them manually, but I would like to take
advantage of localization. How do I get a localized version of a
Properties object with my messages in it?

-Original Message-
From: Wilhelmsen Tor Iver [mailto:toriv...@arrive.no] 
Sent: Thursday, July 29, 2010 11:19 PM
To: users@wicket.apache.org
Subject: SV: Localizer in a new Thread

 To clarify, I want to use Localizer#getString(...) in a thraed I 
 create.
 I have seen other posts on this issue, but haven't been able to figure

 out the solution.

The Localizer.getString() looks for its messages in Wicket's property
file structure, which depends on Application, the resource-oriented
classes, hierarchies and so forth. Your best bet is to pre-read the
values you need into a Properties object that you pass to the thread
code.

- Tor Iver

-
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: Localizer in a new Thread

2010-07-30 Thread Fernando Wermus
Ale,
   Related to what you have mentioned. I render mails with some
mockHTTPrequest and mockeHTTPResponse, etc. But, I need to render mails in a
different thread than wicket's one. I have another servlet that runs Blazeds
(Flex) where I also need to render some mails, but  I got  There is no
application
attached to current thread According to what you mentioned, could I
solve this issue?

thanks in advance.

On Fri, Jul 30, 2010 at 5:46 AM, Alex Objelean alex.objel...@gmail.comwrote:


 There was a long discussion about this. One of the proposal was to use
 InheritableThreadLocal which would solve this problem, but there was a lot
 of concerns about this approach.

 The solution I have found was this:
 If you create the thread with ExecutorService, you could do the following:

final ExecutorService service = new ScheduledThreadPoolExecutor(1) {
  @Override
  protected void beforeExecute(final Thread t, final Runnable r) {
Application.set(app);
  };
  @Override
  protected void afterExecute(final Runnable r, final Throwable t) {
Application.unset();
  }
};

 and execute you thread like this:
 service.submit(new Runnable() {
@Override
public void run() {
  //do stuff
}
  });

 This will ensure that Application is accessible from within newly created
 thread.

 Alex
 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html
 Sent from the Wicket - User 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




-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus


Re: Wicket and JEE6

2010-07-30 Thread Erik Brakkee
I have found an elegant solution to the serialization problem.
Basically, in the ComponentInstantiationListener that perform injection, I
am also attaching a new InjectionBehavior. The injection behavior has a
private transient boolean field indicating whether injections are up to
date. Upon serialization/deserialization of a component, this field is reset
to false because it is transient. As a result, I can detect in the
beforeRender() method of the behavior whether I need to do injection.

The code of the component instantiationlistener is now as follows:

@Override
public void onInstantiation(Component aComponent) {
injector.inject(aComponent);
aComponent.add(new InjectionBehavior());
}

With the InjectionBahavior defined as follows:

public class InjectionBehavior extends AbstractBehavior {

private transient boolean injectionUptodate;

public InjectionBehavior() {
injectionUptodate = true;
}

@Override
public void beforeRender(Component aComponent) {
if (!injectionUptodate) {
InjectorBuilder.getInjector().inject(aComponent);
injectionUptodate = true;
}
}
}

This solution prevents unnecessary injection. This is required because
injection is expensive. For a simple class with only one injection I
measured only 1400 injections per second (I understand the weld project is
working on improving performance at the moment).


Another part of the solution is to be able to deal with detachable models
that need to keep a reference to an entity manager. The problem is that
these detachable models are also serialized/deserialized. For this I am
using a similar trick now to create a dynamic proxy of an entity manager
that delegates to a dynamically looked up version of the entity manager. The
lookup is done by creating a dummy object with a @persistenceContet in it
and using CDI to inject/obtain the entity manager. Here similarly, the
lookup caches the entity manager as a transient reference so it knows when
to recompute the entity manager.

The object that does this lookup is in fact a managed bean with a producer
method annoted with @Produces @ApplicationDatabase and @PersistenceContext:

public class EntityManagerLookup implements Lookup {

private static class EmHolder {
@PersistenceContext
private EntityManager em;

public EntityManager getEm() {
return em;
}
}

private transient EntityManager em;

@Override
public Object lookup() throws Exception {
if (em == null) {
EmHolder holder = new EmHolder();
InjectorBuilder.getInjector().inject(holder);
em = holder.getEm();
}
return em;
}

@Produces
@ApplicationDatabase
@PersistenceContext
public EntityManager getDefaultEntityManager() {
LookupProxyFactoryEntityManager factory = new
LookupProxyFactoryEntityManager(
EntityManager.class, new EntityManagerLookup());
return factory.getProxy();
}

}

Using this method, I can inject this serialization-safe entitymanager into
any object using

@Inject @ApplicationDatabase EntityManager entityManager;

So, in fact, I have a two-part solution. First of all it is robust in the
sense that @PersistenceContext still works. Second, I can also use a custom
injection to obtain serialization safe entity managers. When the entity
manager is obtained using the custom method however, problems can still
exist with for instance application scoped objects which also appear to be
serialized (this is in fact wrong as the objects will no longer be
application scoped because several copies are created).

A consequence of this solution is that all injected dependencies should be
declared as transient because this is more efficient.

The code for this can be found at http://utils.wamblee.org (wicket/inject,
support/inject, and support/cdi).


Re: Localizer in a new Thread

2010-07-30 Thread Alex Objelean

Yes, the solution I've mentioned in previous post should solve your problem.

Alex

On 30 July 2010 22:44, Fernando Wermus-3 [via Apache Wicket] 
ml-node+2308410-419528218-229...@n4.nabble.comml-node%2b2308410-419528218-229...@n4.nabble.com
 wrote:

 Ale,
Related to what you have mentioned. I render mails with some
 mockHTTPrequest and mockeHTTPResponse, etc. But, I need to render mails in
 a
 different thread than wicket's one. I have another servlet that runs
 Blazeds
 (Flex) where I also need to render some mails, but  I got  There is no
 application
 attached to current thread According to what you mentioned, could I
 solve this issue?

 thanks in advance.

 On Fri, Jul 30, 2010 at 5:46 AM, Alex Objelean [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2308410i=0wrote:


 
  There was a long discussion about this. One of the proposal was to use
  InheritableThreadLocal which would solve this problem, but there was a
 lot
  of concerns about this approach.
 
  The solution I have found was this:
  If you create the thread with ExecutorService, you could do the
 following:
 
 final ExecutorService service = new ScheduledThreadPoolExecutor(1) {
   @Override
   protected void beforeExecute(final Thread t, final Runnable r) {
 Application.set(app);
   };
   @Override
   protected void afterExecute(final Runnable r, final Throwable t) {
 Application.unset();
   }
 };
 
  and execute you thread like this:
  service.submit(new Runnable() {
 @Override
 public void run() {
   //do stuff
 }
   });
 
  This will ensure that Application is accessible from within newly created

  thread.
 
  Alex
  --
  View this message in context:
 
 http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.htmlhttp://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html?by-user=t
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
  -
  To unsubscribe, e-mail: [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=2308410i=1
  For additional commands, e-mail: [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=2308410i=2
 
 


 --
 Fernando Wermus.

 www.linkedin.com/in/fernandowermus


 --
  View message @
 http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2308410.html
 To unsubscribe from RE: Localizer in a new Thread, click 
 herehttp://apache-wicket.1842946.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=YWxleC5vYmplbGVhbkBnbWFpbC5jb218MjMwNzczMnwtNDA5MTE1Njc3.




-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2308459.html
Sent from the Wicket - User mailing list archive at Nabble.com.