Re: Submitting values for null associations

2014-02-11 Thread Marios Skounakis
I'm not sure there is a very clean solution.

When switching to edit mode, you could set the User's Job to a new Job
instance if it is null. You don't have to reattach/reassign any form
components if you simply update the AbstractEntityModel's object. I.e. you
either do
model.getModelObject().setJob(new Job())
or you do model.setModelObject()

You will of course have to revert the job property back to null before
saving if all its properties are empty.

I would implement a Job#isEmpty() method to help me decide if I need to set
user.job to null before saving to the db.

Note you may also have to delete an existing Job record if the user goes
ahead and updates it's name to null.

Marios



On Tue, Feb 11, 2014 at 4:22 PM, ChambreNoire  wrote:

> I forgot to mention, the reason I don't systematically make a new Job
> instance is that when saving the form hibernate creates a new Job instance
> which is effectively empty if no Job details have been input.
>
> Chambre
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664369.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: Nested Forms

2014-01-10 Thread Marios Skounakis
Html does not support nested forms. Wicket works around this limitation and
allows form nesting. I think it changes the html so that the inner form
tags become span tags. This means that whenever any of the forms needs to
be posted, everything is posted since in the result html there's only one
form element.

Wicket provides some mechanisms so that submitting the outer form submits
(validates and updates models) the inner forms too, whereas submitting an
inner form only validates and updates the model for this inner form.

You can find more details in the wicket free guide (
https://code.google.com/p/wicket-guide) and at
https://cwiki.apache.org/confluence/display/WICKET/Nested+Forms (not sure
how up-to-date is the latter).



On Fri, Jan 10, 2014 at 7:04 PM, gmparker2000 wrote:

> When submitting an inner form it appears that the request contains all of
> the
> outer and inner form fields.  Is this the expected behaviour?  From what I
> can see it appears that the outer form is submitted, and only the inner
> form
> parameters are validated and used for model updates.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Nested-Forms-tp4663620.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: Auto-save feature

2014-01-07 Thread Marios Skounakis
In a similar case I've used a wrapper around validators which controls
whether they run or not. This way you can automatically parse the form
component tree, find all validators and wrap them in a new Validator that
runs them only if needed.

I've done this because I wanted to be able to have the standard wicket
validators run in onValidateModelObjects(). I.e. I wanted my model to be
updated even if some validations did not pass.

So here's the basic idea (this is slightly modified from my actual code so
it may have small errors).

public abstract class ValidatorWrapper implements IValidator {
IValidator validator;
 public DelayedValidator(IValidator validator) {
super();
this.validator = validator;
}

protected abstract boolean shouldRun();

@Override
public void validate(IValidatable validatable) {
if (!shouldRun())
return;
if (validatable.getValue() == null) {
if (!(validator instanceof INullAcceptingValidator)) {
return;
}
}
validator.validate(validatable);
}
}

It is reasonably easy to extend this for FormValidators as well.

This does not handle the case of conversion errors, i.e. in an Integer
TextField if the user input is not a valid integer, it won't update the
model object. So if you auto-save and the reload, such fields will be
empty. This is something that would actually be a lot of work to handle
because you would need a custom model that would actually store string
values.

Cheers
Marios


On Tue, Jan 7, 2014 at 9:32 PM, gmparker2000 wrote:

> Interesting but unfortunately our form is very complex with repeaters, etc.
> So I don't think this would work for us.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Auto-save-feature-tp4663517p4663522.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: Generate PDF

2013-12-23 Thread Marios Skounakis
In case your requirements for pdf generation are not very complex, you
could use FlyingSaucer (https://xhtmlrenderer.java.net/). It basically
converts html to pdf. So you can create your output in html and then
convert it to pdf using flying saucer.


On Mon, Dec 23, 2013 at 10:45 PM, Niranjan Rao  wrote:

> Do you want to use it in wicket application or java application? The link
> is for csharp based tool and will not work in wicket application. But it
> looks like they have java API also http://www.rasteredge.com/java-imaging/
> .
>
> Personally we use apache pdf box. We don't create PDF, but we do analyze
> PDF files using the API. Reasonably happy with PDF box.
>
>
> On 12/22/2013 10:38 PM, Abigail wrote:
>
>> Hi there
>> I am a beginner of PDF processing .And i am looking for a  PDF processing
>> 
>> program.I know there are many third party program which supports to
>> process
>> PDF files.But i want to get a free trial package before i decided to
>> purchase it.Thanks for any suggestions.
>>
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.
>> n4.nabble.com/Generate-PDF-tp3651354p4663182.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: Session invalidation and background thread

2013-11-26 Thread Marios Skounakis
Martin,

I understand this is getting a bit off topic so we could as well drop it.

I understand that the threads and session will eventually be garbage
collected (go to /dev/null as you said). But this is not necessarily bad,
is it? In my case these threads are updating an application-wide cache. So
it is acceptable that they update the cache even if the session has been
unbound, and when they are done they may as well be gc'ed.

Am I missing something?
Thanks
Marios


On Sun, Nov 24, 2013 at 1:13 PM, Martin Grigorov wrote:

> Hi,
>
>
> On Sat, Nov 23, 2013 at 2:11 PM, Marios Skounakis 
> wrote:
>
> > Bas,
> >
> > Thanks for your answer. I understand what you're saying and you're right.
> > If I were designing the application now I'd do one of your suggestions.
> >
> > But unfortunately we've written most of the code and these threads now
> > depend on spring session beans. Right now B is pretty much the only
> viable
> > option. And we may go ahead and implement it (or maybe the polling
> > alternative).
> >
> > I'd like to repeat my question though, if only to gain some deeper
> > understanding of what's going on under the hood. Is there any danger if
> we
> > leave things as they are and we don't implement neither A nor B? What is
> > going to happen to the session? Will it still be invalidated, maybe
> causing
> > exceptions to the threads, or will it be kept around until the threads
> > finish? And once they all finish, will it be released or not?
> >
>
> What happens is that you will keep a reference to a plain object that is
> not managed by anything anymore.
> I.e. your case is a normal memory leak.
> Whatever you store in such session will go to /dev/null.
>
> I think you should consult with Servlet API -
>
> http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpSessionListener.html
> .
> This listener will inform you when a new session is bound and when one is
> destroyed. Your threads should work only with the currently active/live
> sessions.
>
>
> >
> > Cheers
> > Marios
> >
> >
> > On Sat, Nov 23, 2013 at 1:26 PM, Bas Gooren  wrote:
> >
> > > Hi,
> > >
> > > I guess it depends on the lifecycle of those threads how I would handle
> > > this.
> > > Suppose the session is invalidated and destroyed, what should happen to
> > > the threads? Do they continue (A) or do they need to stop (B)?
> > >
> > > A) In this case I would not depend on the session at all, if possible.
> > > Simply copy the OAuth token to a private variable in your threads.
> > >
> > > B) Instead of the threads "polling" to see if the session is still
> there,
> > > I'd turn things around. Keep track of sessions-and-their-threads
> > somewhere.
> > > Register a session invalidation listener, and when the session is
> > > invalidated, you can run some code to neatly stop and clean up your
> > threads.
> > >
> > > Met vriendelijke groet,
> > > Kind regards,
> > >
> > > Bas Gooren
> > >
> > > schreef Marios Skounakis op 22-11-2013 23:45:
> > >
> > >  Hi all,
> > >>
> > >> This is maybe a Spring question but as my app is a wicket app and I
> use
> > >> this list regularly and everyone is very helpful I thought I'd ask
> here
> > >> first.
> > >>
> > >> I have a RequestCycleListener which during onBeginRequest()
> > conditionally
> > >> spawns some background threads and runs them using an Executor. These
> > >> threads need access to an oauth token which is stored in the session.
> > So I
> > >> create my threads in the RequestCycleListener, give them a reference
> to
> > >> the
> > >> wicket session and run them in the background thread. The threads also
> > >> have
> > >> a reference to Spring's session (via spring's
> > >> RequestContextHolder.getRequestAttributes()/setRequestAttributes()).
> > >> Actually the dependence on spring session is much harder to alleviate
> as
> > >> they often need to access session scoped beans.
> > >>
> > >> I'm wondering what exactly happens if I try to invalidate the session
> > >> (e.g.
> > >> when the user logs out) while such a background thread is running. Is
> > >> there
> > >> a possibility for harmful side-effects?
> > >>
> > >> Should I consider adding code to my threads to periodically check that
> > the
> > >> session is still valid? After all they do have a reference to the
> > session
> > >> object, so this sounds feasible.
> > >>
> > >> If it matters at all, I'm using Tomcat.
> > >>
> > >> Thanks in advance,
> > >> Marios
> > >>
> > >>
> > >
> >
>


Re: Session invalidation and background thread

2013-11-23 Thread Marios Skounakis
Bas,

Thanks for your answer. I understand what you're saying and you're right.
If I were designing the application now I'd do one of your suggestions.

But unfortunately we've written most of the code and these threads now
depend on spring session beans. Right now B is pretty much the only viable
option. And we may go ahead and implement it (or maybe the polling
alternative).

I'd like to repeat my question though, if only to gain some deeper
understanding of what's going on under the hood. Is there any danger if we
leave things as they are and we don't implement neither A nor B? What is
going to happen to the session? Will it still be invalidated, maybe causing
exceptions to the threads, or will it be kept around until the threads
finish? And once they all finish, will it be released or not?

Cheers
Marios


On Sat, Nov 23, 2013 at 1:26 PM, Bas Gooren  wrote:

> Hi,
>
> I guess it depends on the lifecycle of those threads how I would handle
> this.
> Suppose the session is invalidated and destroyed, what should happen to
> the threads? Do they continue (A) or do they need to stop (B)?
>
> A) In this case I would not depend on the session at all, if possible.
> Simply copy the OAuth token to a private variable in your threads.
>
> B) Instead of the threads "polling" to see if the session is still there,
> I'd turn things around. Keep track of sessions-and-their-threads somewhere.
> Register a session invalidation listener, and when the session is
> invalidated, you can run some code to neatly stop and clean up your threads.
>
> Met vriendelijke groet,
> Kind regards,
>
> Bas Gooren
>
> schreef Marios Skounakis op 22-11-2013 23:45:
>
>  Hi all,
>>
>> This is maybe a Spring question but as my app is a wicket app and I use
>> this list regularly and everyone is very helpful I thought I'd ask here
>> first.
>>
>> I have a RequestCycleListener which during onBeginRequest() conditionally
>> spawns some background threads and runs them using an Executor. These
>> threads need access to an oauth token which is stored in the session. So I
>> create my threads in the RequestCycleListener, give them a reference to
>> the
>> wicket session and run them in the background thread. The threads also
>> have
>> a reference to Spring's session (via spring's
>> RequestContextHolder.getRequestAttributes()/setRequestAttributes()).
>> Actually the dependence on spring session is much harder to alleviate as
>> they often need to access session scoped beans.
>>
>> I'm wondering what exactly happens if I try to invalidate the session
>> (e.g.
>> when the user logs out) while such a background thread is running. Is
>> there
>> a possibility for harmful side-effects?
>>
>> Should I consider adding code to my threads to periodically check that the
>> session is still valid? After all they do have a reference to the session
>> object, so this sounds feasible.
>>
>> If it matters at all, I'm using Tomcat.
>>
>> Thanks in advance,
>> Marios
>>
>>
>


Session invalidation and background thread

2013-11-22 Thread Marios Skounakis
Hi all,

This is maybe a Spring question but as my app is a wicket app and I use
this list regularly and everyone is very helpful I thought I'd ask here
first.

I have a RequestCycleListener which during onBeginRequest() conditionally
spawns some background threads and runs them using an Executor. These
threads need access to an oauth token which is stored in the session. So I
create my threads in the RequestCycleListener, give them a reference to the
wicket session and run them in the background thread. The threads also have
a reference to Spring's session (via spring's
RequestContextHolder.getRequestAttributes()/setRequestAttributes()).
Actually the dependence on spring session is much harder to alleviate as
they often need to access session scoped beans.

I'm wondering what exactly happens if I try to invalidate the session (e.g.
when the user logs out) while such a background thread is running. Is there
a possibility for harmful side-effects?

Should I consider adding code to my threads to periodically check that the
session is still valid? After all they do have a reference to the session
object, so this sounds feasible.

If it matters at all, I'm using Tomcat.

Thanks in advance,
Marios


Re: Conditionally include header item when page contains ajax components

2013-11-15 Thread Marios Skounakis
On Fri, Nov 15, 2013 at 9:18 AM, Martin Grigorov wrote:

> Hi,
>
>
> On Thu, Nov 14, 2013 at 10:43 PM, Nick Pratt  wrote:
>
> > Understood.
> >
> > Martin - (for my own curiousity now) would it be possible and would there
> > be any benefit to replacing the default Wicket jQuery resource reference
> > with a custom veil.js ResourceReference that also included the packaged
> > Wicket jquery resource ref as a dependency (i.e. configure this all in
> > Application.init() )?
> >
>
> Yes. This will work as well.
>
> getJavaScriptLibrarySettings().setWicketAjaxReference(veilJsThatDependsOnOriginalWicketAjaxReference)
>

It's probably faster too...



>
>
> >
> > Nick
> >
> >
> > On Thu, Nov 14, 2013 at 3:04 PM, Marios Skounakis 
> > wrote:
> >
> > > I probably wasn't clear enough.
> > >
> > > Here's my case:
> > >
> > > BasePage.renderHead() adds veil.js as javascript resource reference.
> > >
> > > All my pages inherit from BasePage. But veil.js is only useful when a
> > page
> > > has wicket ajax.
> > >
> > > If I declare that veil.js has a dependency on jquery then the result is
> > > that all pages get both veil.js and jquery. What I want is that pages
> > that
> > > don't have ajax (i.e. no Wicket-Ajax or Wicket-Event libraries) don't
> > > include veil.js. I could do it on a per component basis but this would
> be
> > > cumbersome and error prone. So instead I used Martin's solution and
> > > conditionally render veil.js only if the headerResponse renders
> > > Wicket-Event.
> > >
> > >
> > > On Thu, Nov 14, 2013 at 5:09 PM, Nick Pratt  wrote:
> > >
> > > > Then you're doing something odd :-)
> > > >
> > > > If you have dependencies like this:
> > > >
> > > > CustomComponent --> Custom JS Reference (and this is added in the
> > public
> > > > void renderHead( Component component, IHeaderResponse response )
> > method)
> > > > --> Wicket's JQuery JS Reference
> > > >
> > > > Page A (no Ajax components or components depending on Wicket's jquery
> > > ref)
> > > > Page B --> CustomComponent  (Page B being a copy of Page with a
> single
> > > > instance of your CustomComponent)
> > > >
> > > > When you load Page A, the JS will not be loaded.
> > > > When you load Page B, both the Wicket JS and the custom JS will be
> > added
> > > to
> > > > the page.
> > > >
> > > > If you are seeing Jquery being loaded in Page A then some component
> on
> > > that
> > > > page requires the Wicket JS libraries and is causing it to be added.
> > > >
> > > > N
> > > >
> > > >
> > > >
> > > > On Thu, Nov 14, 2013 at 8:56 AM, Marios Skounakis 
> > > > wrote:
> > > >
> > > > > Thanks Martin, this worked well.
> > > > >
> > > > > Sebastien and Nick, I tried the solution with
> > > > JQueryPluginResourceReference
> > > > > but this indeed caused JQuery to be loaded in non ajax pages.
> > > > >
> > > > >
> > > > > On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov <
> > mgrigo...@apache.org
> > > > > >wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > You can create custom IHeaderResponseDecorator and by using
> custom
> > > > > > IHeaderResponse you can check for contributions
> > > > > > of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference
> > > > > > See
> > > > > >
> > > > >
> > > >
> > >
> >
> http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0
> > > > > >  and
> > http://wicketinaction.com/2012/07/wicket-6-resource-management/
> > > > > >
> > > > > >
> > > > > > On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis <
> > msc...@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > If I'm not mistaken this will cause JQuery to be included
> > whenever
> > > my
> > > > > js
> > > > > > > reference is included. Effectively this will cause non-aja

Re: Conditionally include header item when page contains ajax components

2013-11-14 Thread Marios Skounakis
I probably wasn't clear enough.

Here's my case:

BasePage.renderHead() adds veil.js as javascript resource reference.

All my pages inherit from BasePage. But veil.js is only useful when a page
has wicket ajax.

If I declare that veil.js has a dependency on jquery then the result is
that all pages get both veil.js and jquery. What I want is that pages that
don't have ajax (i.e. no Wicket-Ajax or Wicket-Event libraries) don't
include veil.js. I could do it on a per component basis but this would be
cumbersome and error prone. So instead I used Martin's solution and
conditionally render veil.js only if the headerResponse renders
Wicket-Event.


On Thu, Nov 14, 2013 at 5:09 PM, Nick Pratt  wrote:

> Then you're doing something odd :-)
>
> If you have dependencies like this:
>
> CustomComponent --> Custom JS Reference (and this is added in the public
> void renderHead( Component component, IHeaderResponse response ) method)
> --> Wicket's JQuery JS Reference
>
> Page A (no Ajax components or components depending on Wicket's jquery ref)
> Page B --> CustomComponent  (Page B being a copy of Page with a single
> instance of your CustomComponent)
>
> When you load Page A, the JS will not be loaded.
> When you load Page B, both the Wicket JS and the custom JS will be added to
> the page.
>
> If you are seeing Jquery being loaded in Page A then some component on that
> page requires the Wicket JS libraries and is causing it to be added.
>
> N
>
>
>
> On Thu, Nov 14, 2013 at 8:56 AM, Marios Skounakis 
> wrote:
>
> > Thanks Martin, this worked well.
> >
> > Sebastien and Nick, I tried the solution with
> JQueryPluginResourceReference
> > but this indeed caused JQuery to be loaded in non ajax pages.
> >
> >
> > On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov  > >wrote:
> >
> > > Hi,
> > >
> > > You can create custom IHeaderResponseDecorator and by using custom
> > > IHeaderResponse you can check for contributions
> > > of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference
> > > See
> > >
> >
> http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0
> > >  and http://wicketinaction.com/2012/07/wicket-6-resource-management/
> > >
> > >
> > > On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis 
> > > wrote:
> > >
> > > > If I'm not mistaken this will cause JQuery to be included whenever my
> > js
> > > > reference is included. Effectively this will cause non-ajax pages to
> > load
> > > > javascript which applies only to ajax requests.
> > > >
> > > > What I want is the opposite: to not include my js reference when the
> > page
> > > > does not have any ajax.
> > > >
> > > >
> > > > On Thu, Nov 14, 2013 at 2:04 PM, Sebastien  wrote:
> > > >
> > > > > Hi Marios,
> > > > >
> > > > > IMO the best way IMO is to make your js reference extending
> > > > > JQueryPluginResourceReference (wicket 6)
> > > > >
> > > > > Best regards,
> > > > > Sebastien.
> > > > >
> > > > >
> > > > > On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis <
> msc...@gmail.com
> > >
> > > > > wrote:
> > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I have a base page from which all my pages inherit. I want to
> > > > > conditionally
> > > > > > include a javascript reference (header item) if the page contains
> > an
> > > > ajax
> > > > > > component. The reference is a veil implementation based on
> BlockUI
> > > > which
> > > > > is
> > > > > > redundant (and also causes a javascript error) if the page has
> not
> > > ajax
> > > > > > (and hence JQuery is not loaded).
> > > > > >
> > > > > > Any suggestions?
> > > > > >
> > > > > > Thanks
> > > > > > Marios
> > > > > >
> > > > >
> > > >
> > >
> >
>


Re: Conditionally include header item when page contains ajax components

2013-11-14 Thread Marios Skounakis
Thanks Martin, this worked well.

Sebastien and Nick, I tried the solution with JQueryPluginResourceReference
but this indeed caused JQuery to be loaded in non ajax pages.


On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov wrote:

> Hi,
>
> You can create custom IHeaderResponseDecorator and by using custom
> IHeaderResponse you can check for contributions
> of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference
> See
> http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0
>  and http://wicketinaction.com/2012/07/wicket-6-resource-management/
>
>
> On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis 
> wrote:
>
> > If I'm not mistaken this will cause JQuery to be included whenever my js
> > reference is included. Effectively this will cause non-ajax pages to load
> > javascript which applies only to ajax requests.
> >
> > What I want is the opposite: to not include my js reference when the page
> > does not have any ajax.
> >
> >
> > On Thu, Nov 14, 2013 at 2:04 PM, Sebastien  wrote:
> >
> > > Hi Marios,
> > >
> > > IMO the best way IMO is to make your js reference extending
> > > JQueryPluginResourceReference (wicket 6)
> > >
> > > Best regards,
> > > Sebastien.
> > >
> > >
> > > On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis 
> > > wrote:
> > >
> > > > Hi all,
> > > >
> > > > I have a base page from which all my pages inherit. I want to
> > > conditionally
> > > > include a javascript reference (header item) if the page contains an
> > ajax
> > > > component. The reference is a veil implementation based on BlockUI
> > which
> > > is
> > > > redundant (and also causes a javascript error) if the page has not
> ajax
> > > > (and hence JQuery is not loaded).
> > > >
> > > > Any suggestions?
> > > >
> > > > Thanks
> > > > Marios
> > > >
> > >
> >
>


Re: Conditionally include header item when page contains ajax components

2013-11-14 Thread Marios Skounakis
If I'm not mistaken this will cause JQuery to be included whenever my js
reference is included. Effectively this will cause non-ajax pages to load
javascript which applies only to ajax requests.

What I want is the opposite: to not include my js reference when the page
does not have any ajax.


On Thu, Nov 14, 2013 at 2:04 PM, Sebastien  wrote:

> Hi Marios,
>
> IMO the best way IMO is to make your js reference extending
> JQueryPluginResourceReference (wicket 6)
>
> Best regards,
> Sebastien.
>
>
> On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis 
> wrote:
>
> > Hi all,
> >
> > I have a base page from which all my pages inherit. I want to
> conditionally
> > include a javascript reference (header item) if the page contains an ajax
> > component. The reference is a veil implementation based on BlockUI which
> is
> > redundant (and also causes a javascript error) if the page has not ajax
> > (and hence JQuery is not loaded).
> >
> > Any suggestions?
> >
> > Thanks
> > Marios
> >
>


Conditionally include header item when page contains ajax components

2013-11-14 Thread Marios Skounakis
Hi all,

I have a base page from which all my pages inherit. I want to conditionally
include a javascript reference (header item) if the page contains an ajax
component. The reference is a veil implementation based on BlockUI which is
redundant (and also causes a javascript error) if the page has not ajax
(and hence JQuery is not loaded).

Any suggestions?

Thanks
Marios


Re: java.util.Properties as Form Model

2013-10-18 Thread Marios Skounakis
An idea is to wrap the Properties object in a class of your own
implementing Map as follows:

class MyProps implements Map {
  Properties props;

  public void put(String key, String value) {
if (value == null) props.remove(key);
else props.put(key, value);
}

This does sound like a bug in PropertyResolver as it should probably test
whether the Map is a Hashtable and call remove() since Hashtable is
documented to throw an NPE when put() is called with a null value.



On Fri, Oct 18, 2013 at 1:55 PM, Andy Van Den Heuvel <
andy.vandenheu...@gmail.com> wrote:

> Hey,
>
> I'm trying to create a form with a CompoundPropertyModel to fill a
> java.util.Properties object dynamically.
>
> Form form = new Form<>("form", new
> CompoundPropertyModel<>(properties));
> form.add(new TextField("host"));
> form.add(new TextField("port"));
>
> This works correct when I start from an empty java.util.Properties object.
> If I have an existing java.util.Properties object (with filled data)
> and I remove the value in the html page, I want the key-value pair to be
> deleted from the Properties object.
>
> With my current implementation I get a stacktrace (because it tries to
> write a null value in the java.util.Properties object)
>
> java.lang.NullPointerException
>  at java.util.Hashtable.put(Hashtable.java:432)
>  at
>
> org.apache.wicket.core.util.lang.PropertyResolver$MapGetSet.setValue(PropertyResolver.java:803)
>  at
>
> org.apache.wicket.core.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:644)
>  at
>
> org.apache.wicket.core.util.lang.PropertyResolver.setValue(PropertyResolver.java:144)
>
>
> Has anybody have an idea how best to create this behaviour?
> Thanks in advance for your help!
>


Re: Ajax behavior that can be reused for multiple components

2013-10-08 Thread Marios Skounakis
Thank you both for your feedback, everything is in place now.

For the record, the code that generates the required javascript now is:

"$('#" + markupId + "').on('blur', '.df', function() {var comp =
$(this).attr('name'); var cid=$(this).attr('id'); var data = {};
data['component']=comp; Wicket.Ajax.post({'u':'" + callbackUrl + "',
'e':'blur', 'c':cid, 'ep': data});});
Passing the component id to Wicket.Ajax.post automatically adds its current
value to the post parameters. So I only had to use 'ep' to pass the
component's name so that AbstractDefaultAjaxBehavior#respond() can know
which component to update.



On Tue, Oct 8, 2013 at 10:49 PM, Ernesto Reinaldo Barreiro <
reier...@gmail.com> wrote:

> This link might be useful too
>
> https://github.com/reiern70/antilia-bits/tree/master/wicket-sparelinks
>
>
>
>
> On Tue, Oct 8, 2013 at 9:31 PM, Marios Skounakis  wrote:
>
> > Hi all,
> >
> > I want to implement an ajax behavior similar to
> > AjaxFormComponentUpdatingBehavior but which can be attached only once to
> a
> > parent container component and issue ajax calls for all contained form
> > components.
> >
> > So what I did was extend AbstractDefaultAjaxBehavior and pretty much copy
> > the logic of AjaxFormComponentUpdatingBehavior respond() except that the
> > component is located via the request parameters.
> >
> > This worked quite ok.
> >
> > I had a lot of trouble with emitting the appropriate javascript. The
> > behavior by default attaches to the container component and does not post
> > anything useful. So I had to resort to adding custom javascript in
> > renderHead().
> >
> > I ended up manually constructing a variable with the post parameters and
> > using jQuery post() to send them to the behavior's callback url.
> >
> > response.render(OnDomReadyHeaderItem
> > .forScript("$('#" + markupId + "').on('blur', '.df',
> > function() {var comp = $(this).attr('name'); var data = {}; data[comp] =
> > $(this).val(); data['component']=comp; data['"
> > + WebRequest.PARAM_AJAX
> > + "']=true; data['"
> > + WebRequest.PARAM_AJAX_BASE_URL
> > + "']=Wicket.Ajax.baseUrl; $.post('"
> > + getCallbackUrl() + "', data);" + "});"));
> > }
> >
> > I wanted to use Wicket.Ajax calls to achieve the same effect but failed
> > miserably in all attempts to use Wicket.Ajax.ajax() or
> Wicket.Ajax.post().
> > It is my understanding that these register event handlers rather than
> issue
> > direct calls.
> >
> > So, how does one use the Wicket.Ajax library to issue an ajax call with
> > custom post parameters? Is there some documentation I am not aware of?
> >
> > Thanks
> > Marios
> >
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>


Ajax behavior that can be reused for multiple components

2013-10-08 Thread Marios Skounakis
Hi all,

I want to implement an ajax behavior similar to
AjaxFormComponentUpdatingBehavior but which can be attached only once to a
parent container component and issue ajax calls for all contained form
components.

So what I did was extend AbstractDefaultAjaxBehavior and pretty much copy
the logic of AjaxFormComponentUpdatingBehavior respond() except that the
component is located via the request parameters.

This worked quite ok.

I had a lot of trouble with emitting the appropriate javascript. The
behavior by default attaches to the container component and does not post
anything useful. So I had to resort to adding custom javascript in
renderHead().

I ended up manually constructing a variable with the post parameters and
using jQuery post() to send them to the behavior's callback url.

response.render(OnDomReadyHeaderItem
.forScript("$('#" + markupId + "').on('blur', '.df',
function() {var comp = $(this).attr('name'); var data = {}; data[comp] =
$(this).val(); data['component']=comp; data['"
+ WebRequest.PARAM_AJAX
+ "']=true; data['"
+ WebRequest.PARAM_AJAX_BASE_URL
+ "']=Wicket.Ajax.baseUrl; $.post('"
+ getCallbackUrl() + "', data);" + "});"));
}

I wanted to use Wicket.Ajax calls to achieve the same effect but failed
miserably in all attempts to use Wicket.Ajax.ajax() or Wicket.Ajax.post().
It is my understanding that these register event handlers rather than issue
direct calls.

So, how does one use the Wicket.Ajax library to issue an ajax call with
custom post parameters? Is there some documentation I am not aware of?

Thanks
Marios


Component.isVisibleInHierarchy() - expensive or not?

2013-10-03 Thread Marios Skounakis
Hi all,

I have a form with a few hundred components and I am calling
isVisibleInHierarchy for each one of them twice. The reason I am doing this
is because I am running some validations in onValidateModelObjects() and I
want them skip validations for invisible components in some cases.

None of the panel components in the hierarchy have any isVisible()
overloads, only some of them call setVisibilityAllowed() in onConfigure().

I just wanted to double check that this approach is not too expensive.

Thanks in advance,
Marios


Re: Unable to find component in Development ONLY

2013-09-15 Thread Marios Skounakis
Wicket has a setting that checks for missing components and throws an
exception in development but does not do so (I think it only logs a
warning) in deployment. You are actually missing component pageTitle...



On Sun, Sep 15, 2013 at 4:40 PM, William Speirs  wrote:

> Turns out that Eclipse was a red harring. The real issue is that when I run
> in Eclipse it runs in development mode but when I run the JAR it is
> deployment mode.
>
> Is that of help to anyone?
>
> Thanks...
>
> Bill-
> On Sep 14, 2013 10:01 PM, "William Speirs"  wrote:
>
> Before anyone/everyone jumps on me, this code works PERFECTLY when I
> build a JAR (using embedded jetty) and run it. However, it fails in
> Eclipse with the following:
>
> Last cause: Unable to find component with id 'pageTitle' in
> [HtmlHeaderContainer [Component id = _header_5]]
> Expected: '_header_5:pageTitle'.
> Found with similar names: 'pageTitle'
>
> So clearly my code + HTML is correct, it's more of an Eclipse issue. I
> realize this isn't an Eclipse mailing list, but does anyone have any
> ideas?
>
> The page I'm trying to render extends a page class, that extends
> another, that extends WebPage. Is this where _header_5 comes from?
>
> Thanks...
>
> Bill-
>


RequestLogger and MDC

2013-08-08 Thread Marios Skounakis
Hi all,

I have run into the following problem with request logger:

I have a RequestCycleListener which populates MDC (logging mapped
diagnostic context) with some custom properties such as the sessionId, the
userId, and some other stuff. The listener populates the MDC in
onBeginRequest and clears the MDC in onEndRequest.

What happens is that log entries written by the RequestLogger have empty
values for these MDC properties. By digging around I discovered that
RequestLogger.log is called in RequestCycle onInternalDetach() which
happens after onEndRequest(). So the MDC has been cleared before
RequestLogger.log() is called.

I think that my approach which uses a RequestCycleListener to populate and
clear the MDC is valid and that the RequestLogger should be amended to do
the logging before the MDC is cleared (at the latest before
RequestCycleListener.onDetach()).

Note that even if the MDC is cleared in RequestCycleListener.onDetach()
this still happens before RequestLogger.log() is called.

Is there something invalid with my approach?

I now have a workaround with a custom RequestLogger which clears the MDC in
log but this is ugly (if you remove the logger you get a leaking MDC). Any
other ideas for workarounds?

Thanks
Marios


RequestLogger - logging page requests only

2013-08-06 Thread Marios Skounakis
Hi all,

I want to customize request logger to only log page requests. I.e. I don't
want resource requests, etc.

I have overridden log(RequestData rd, SessionData sd) as follows:

@Override
protected void log(RequestData rd, SessionData sd) {
if (rd.getResponseTarget() instanceof IPageRequestHandler)
super.log(rd, sd);
}

It seems to be working. Is there something I am missing?

Thanks
Marios


Re: Passing parameters from java code to global ajax call listeners

2013-07-26 Thread Marios Skounakis
Ah, I now realized "data()" is a jquery feature. Now I get it.

Thanks!


On Sat, Jul 27, 2013 at 7:11 AM, Martin Grigorov wrote:

> or #onComponentTag()
> there is also AbstractDefaultAjaxBehavior#configureJson() (or something
> similar. I have no access to the code now)
> the idea is to mark the component/attributes somehow
> On Jul 27, 2013 12:04 AM, "Marios Skounakis"  wrote:
>
> > Martin,
> >
> > Thanks for your answer. I'm not sure I understand though. What does mean
> > "mark any component with data-no-veil attribute"? Use an attribute
> appender
> > to do something? If yes what? Where is this "feature" documented?
> >
> > Thanks
> > Marios
> >
> >
> > On Fri, Jul 26, 2013 at 10:21 AM, Martin Grigorov  > >wrote:
> >
> > > Hi,
> > >
> > > You may mark any component with data-no-veil attribute.
> > > Later you can check with: if ($(attrs.c).data("no-veil") !== null)
> {...}
> > >
> > >
> > > On Fri, Jul 26, 2013 at 1:40 AM, Marios Skounakis 
> > > wrote:
> > >
> > > > Hi all,
> > > >
> > > > I am subscribing to the global ajax call listeners to show and hide a
> > > veil
> > > > during ajax calls. The veil is displayed during all ajax calls. I
> want
> > a
> > > > way for some components / ajax behaviors to opt our from the veil.
> > > >
> > > > What I'm doing now is adding an extra parameter to the ajaxAttributes
> > > and I
> > > > am checking for it in the beforeSend listener as shown in the code
> > below.
> > > >
> > > > Is there a better way to handle this?
> > > >
> > > > -- setup
> > > >
> > > > Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
> > > > jqXHR, settings ) {
> > > >showBusysign(jqXHR)
> > > > });
> > > >Wicket.Event.subscribe('/ajax/call/complete', function(
> attributes,
> > > > jqXHR, textStatus) {
> > > >hideBusysign()
> > > > });
> > > >
> > > > -- showing the veil:
> > > > function showBusysign(jqXHR) {
> > > >  if(typeof jqXHR.ep != 'undefined') {
> > > >  for (i=0; i > > > 'noveil') {return;}};
> > > >  }
> > > > // go ahead and show the veil
> > > >
> > > > -- java code:
> > > > @Override
> > > > protected void updateAjaxAttributes(AjaxRequestAttributes
> attributes) {
> > > > super.updateAjaxAttributes(attributes);
> > > > attributes.getExtraParameters().put("noveil", "1");
> > > > }
> > > >
> > > >
> > > > Thanks in advance,
> > > > Marios
> > > >
> > >
> >
>


Re: Passing parameters from java code to global ajax call listeners

2013-07-26 Thread Marios Skounakis
Martin,

Thanks for your answer. I'm not sure I understand though. What does mean
"mark any component with data-no-veil attribute"? Use an attribute appender
to do something? If yes what? Where is this "feature" documented?

Thanks
Marios


On Fri, Jul 26, 2013 at 10:21 AM, Martin Grigorov wrote:

> Hi,
>
> You may mark any component with data-no-veil attribute.
> Later you can check with: if ($(attrs.c).data("no-veil") !== null) {...}
>
>
> On Fri, Jul 26, 2013 at 1:40 AM, Marios Skounakis 
> wrote:
>
> > Hi all,
> >
> > I am subscribing to the global ajax call listeners to show and hide a
> veil
> > during ajax calls. The veil is displayed during all ajax calls. I want a
> > way for some components / ajax behaviors to opt our from the veil.
> >
> > What I'm doing now is adding an extra parameter to the ajaxAttributes
> and I
> > am checking for it in the beforeSend listener as shown in the code below.
> >
> > Is there a better way to handle this?
> >
> > -- setup
> >
> > Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
> > jqXHR, settings ) {
> >showBusysign(jqXHR)
> > });
> >Wicket.Event.subscribe('/ajax/call/complete', function( attributes,
> > jqXHR, textStatus) {
> >hideBusysign()
> > });
> >
> > -- showing the veil:
> > function showBusysign(jqXHR) {
> >  if(typeof jqXHR.ep != 'undefined') {
> >  for (i=0; i > 'noveil') {return;}};
> >  }
> > // go ahead and show the veil
> >
> > -- java code:
> > @Override
> > protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
> > super.updateAjaxAttributes(attributes);
> > attributes.getExtraParameters().put("noveil", "1");
> > }
> >
> >
> > Thanks in advance,
> > Marios
> >
>


Passing parameters from java code to global ajax call listeners

2013-07-25 Thread Marios Skounakis
Hi all,

I am subscribing to the global ajax call listeners to show and hide a veil
during ajax calls. The veil is displayed during all ajax calls. I want a
way for some components / ajax behaviors to opt our from the veil.

What I'm doing now is adding an extra parameter to the ajaxAttributes and I
am checking for it in the beforeSend listener as shown in the code below.

Is there a better way to handle this?

-- setup

Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
jqXHR, settings ) {
   showBusysign(jqXHR)
});
   Wicket.Event.subscribe('/ajax/call/complete', function( attributes,
jqXHR, textStatus) {
   hideBusysign()
});

-- showing the veil:
function showBusysign(jqXHR) {
 if(typeof jqXHR.ep != 'undefined') {
 for (i=0; i

Re: Mutliple forms - single login popup

2013-07-20 Thread Marios Skounakis
Jeff,

What you should do is set the close/submit callback of the jquery login
popup before it's shown. This assumes that you show it using an ajax call
and not direct javascript. You should set the close callback to execute the
AjaxFormSubmitBehavior linked with the particular form that you want to
submit after the user has successfully logged on.

I.e. get the javascript that calls the AjaxFormSubmitBehavior by
behavior.getCallbackScript() and set it as the jquery dialog close callback.


Marios


On Sat, Jul 20, 2013 at 6:49 AM, Jeff Schneller  wrote:

> Validation could determine if the user is logged in or not.  But how would
> the login form know which form to continue submitting after a successful
> login?
>
>
> On Friday, July 19, 2013 at 5:12 AM, Stefan Renz wrote:
>
> > Hi Jeff,
> >
> > could you use an AjaxSubmitLink and treat unauthenticated users as a
> validation failure so that you end up in #onError() of your link? That way,
> you can keep the submission login in Form#onSubmit()...
> >
> > Bye
> > Stefan
> >
> > Jeff Schneller wrote:
> > > Easy enough to implement when 1 form with submit button on page. Much
> more difficult when there are N forms with a submit button on a page. Each
> modal would need to have a different onSubmit() behavior so that the
> correct form is processed after the authentication occurs.
> > >
> > >
> > >
> > > On Sunday, July 14, 2013 at 11:38 PM, Paul BorÈ™ wrote:
> > >
> > > > So what's stopping you from doing so again?
> > > >
> > > > You simply keep the same conditions, if not logged you show the
> modal pop-up with the authentication form. User clicks submit on the login
> form and inside the onSubmit() of the form/button you run your
> authentication and if it passes you post the data, if not you give an error.
> > > >
> > > > ~ Thank you,
> > > > Paul Bors
> > > >
> > > > On Jul 14, 2013, at 10:07 AM, Jeff Schneller  j...@mootus.com)> wrote:
> > > >
> > > > > Paul -
> > > > >
> > > > > That is how I am doing it. But I want the buttons to always appear
> even if not logged in. Then when clicked a modal is shown to login through
> a form and then the button action is finally executed.
> > > > >
> > > > > On Sunday, July 14, 2013 at 1:15 AM, Paul Bors wrote:
> > > > > > Keep a flag in your customized Session for when the user is
> logged in. I keep the ID of the user record from the db so that if I need
> the user POJO I can lazy load it later (say to e-mail the user or to show
> the user's name under the My Profile page etc).
> > > > > >
> > > > > > If that is null, then show your pop-up, if valid then show your
> button.
> > > > > >
> > > > > > ~ Thank you,
> > > > > > Paul Bors
> > > > > >
> > > > > > -Original Message-
> > > > > > From: Jeff Schneller [mailto:j...@mootus.com]
> > > > > > Sent: Sunday, July 14, 2013 12:13 AM
> > > > > > To: users@wicket.apache.org (mailto:users@wicket.apache.org)
> > > > > > Subject: Mutliple forms - single login popup
> > > > > >
> > > > > > Using 1.5.x.
> > > > > >
> > > > > > I have multiple forms (minimum of 2 but could be any number) on
> my page being put on the page as a ListView. Each form has its own model
> and 2 buttons within it that perform some action on its model. Similar to
> the facebook newsfeed where each news article has its own like and comment
> button. I have a login form on the page being shown as a jquery modal
> window.
> > > > > >
> > > > > > My requirement is that the user must be logged in before either
> button click is processed. I have code that works but only for one form.
> > > > > >
> > > > > > I want the button click to perform the business logic when user
> is logged in and if not logged in - show a modal login form, after
> successful login then perform the business logic.
> > > > > >
> > > > > > What is the best/easiest way to do this?
> > > > > >
> > > > > > Jeff Schneller
> > > > > > Co-Founder/CTO, Mootus (http://www.mootus.com) 
> > > > > > j...@mootus.com(mailto:
> a...@mootus.com)
> > > > > > M: 1-617-851-0200
> > > > > > Skype: jeff.schneller
> > > > > >
> > > > > > LinkedIn (http://www.linkedin.com/in/jeffschneller) | Twitter (
> https://twitter.com/Mootusco) | Website (http://www.mootus.com/)
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> -
> > > > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org(mailto:
> users-unsubscr...@wicket.apache.org)
> > > > > > For additional commands, e-mail: 
> > > > > > users-h...@wicket.apache.org(mailto:
> users-h...@wicket.apache.org)
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > -
> > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org (mailto:
> users-unsubscr...@wicket.apache.org)
> > > > For additional commands, e-mail: users-h...@wicket.apache.org(mailto:
> users-h...@wicket.apache.org)
> > > >
> > > >
> > > >
> > >
> > 

Re: FormComponent independent from the Model/Model object

2013-07-09 Thread Marios Skounakis
If you want to change the state of the input fields via javascript then do
what Richard said. I guess since you are using an AjaxCheckBox you want to
do it on the server side via ajax. So, here's what you need to do:

add a boolean property to the Panel (e.g. "componentsEnabled") and bind
AjaxCheckBox to it: form.add(new AjaxCheckBox("anyStupidId", new
PropertyModel(this, "componentsEnabled")).

Now whenever the checkbox is updated, the change is reflected to the
componentsEnabled property. You can use this property in the onConfigure
method of the panel or the individual components to alter their state:
e.g. form.add(new TextField("name") {
 public void onConfigure() {
   setEnabled(componentsEnabled);
 }
});

To get the update working after the checkbox is clicked you need to handle
its onUpdate method and add the components whose change should change to
the ajax request target.

Hope this helps,
Marios


On Tue, Jul 9, 2013 at 8:58 PM, Dmitriy Neretin <
dmitriy.nere...@googlemail.com> wrote:

> Hi everyone,
>
> I have a dummy question:
>
> If I have a panel with a form (not everything is my code) ->
>
> public class MyPanel{
>
>   public MyPanel(id, IModel model){
> super(id, new CompoundPropertyModel(model);
> 
> Form form = new Form("id", model);
> form.add(new AjaxCheckBox("anyStupidId");
> add(form);
>
>  }
>
> }
>
> And I want to add a Component (AjaxCheckBox) to the form above, but this
> component shouldn't have anything to do with a model object. It's purpose
> is just a change the state of the input fields. If I check the box the
> field should be deactivated and vice versa. Nothing more.
>
> My problem is, that Wicket thinks (and I even know  why :)) the
> "anyStupidId" is a field of MyObj and tries to change the value... Well,
> the checkbox should be inside of the form, but I don't know if is it
> possible to make this checkbox independent from the Model handling... How
> can I tell wicket, "hey dude, anyStupidId has nothing to do with MyObj, it
> is really just a stupid id"
>
> Regards,
> Dmitriy
>


Re: What is the purpose of Validatable.model?

2013-06-27 Thread Marios Skounakis
Thank you both for your answers.

I wonder what would be best if you want to use the same validation
framework in multiple scenarios. I have a domain object that can be updated
either by a wicket form or by uploading an excel file. I want to have the
same validation logic. Would it be best to use an external validation
component (e.g. beans validation or spring validation) or would it be best
to write some custom code to use wicket validators outside a wicket form?
Do you have any thoughts on this?



On Wed, Jun 26, 2013 at 10:34 AM, Martin Grigorov wrote:

> Hi,
>
> Additionally the validatable's model brings the form component model - this
> is the current value. The validatable's value is the next value. You can
> use them like in a state machine - you can move to a new state/value only
> from some of the other states/values, but not from all.
>
>
> On Wed, Jun 26, 2013 at 8:10 AM, Igor Vaynberg  >wrote:
>
> > this method is useful for validators that integrate with other
> > frameworks. take for example bean-validation framework.
> >
> > a bean validation validator can call getModel(), get the model, cast
> > it to IPropertyReflectionAwareModel, get the property, and retrieve
> > validation annotations associated with it.
> >
> > -igor
> >
> >
> > On Tue, Jun 25, 2013 at 9:53 AM, Marios Skounakis 
> > wrote:
> > > Hi all,
> > >
> > > What is the purpose of Validatable.model?
> > >
> > > I don't seem to be able to find any usages of Validatable.getModel(),
> > > setModel() or model...
> > >
> > > Thanks
> > > Marios
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>


What is the purpose of Validatable.model?

2013-06-25 Thread Marios Skounakis
Hi all,

What is the purpose of Validatable.model?

I don't seem to be able to find any usages of Validatable.getModel(),
setModel() or model...

Thanks
Marios


Re: IInitializer order

2013-06-24 Thread Marios Skounakis
I replace the standard InitializerSRL with MYInitializerSRL so there's no
efficiency problem. It seems better to me to replace the standard
InitializerSRL rather than add an extra SRL but that's just me.

Thanks for your answers, everything is more clear now.


On Mon, Jun 24, 2013 at 10:35 AM, Martin Grigorov wrote:

> On Mon, Jun 24, 2013 at 10:29 AM, Marios Skounakis 
> wrote:
>
> > Martin,
> >
> > What I meant is that now I have my own
> > class MyInitializerStringResourceLoader extends
> > InitializerStringResourceLoader
>
>
> > and its constructor calls
> >
> > super(sort(initializers));
> >
> > and sort() puts my own Initializer first in the initializers list. Is
> this
> > not safe? It does seem to work (whereas before it wasn't working).
> >
> >
> I understood what you said.
> I just explained why it didn't work the first time.
>
> Your solution is a "custom ISRL". It is a bit inefficient but it is
> working.
> It is inefficient because now your application class uses both
> InitializerSRL and MyInitializerSRL, and both of them keep a list of same
> initializers.
> MyISRL doesn't need the list. It needs to use just the class of your
> IInitializer implementation. See the code of InitializerSRL to realize what
> you can cut from your MyISRL.
>
>
> >
> > On Mon, Jun 24, 2013 at 10:20 AM, Martin Grigorov  > >wrote:
> >
> > > The order of the initializers depends on the order of the jars in the
> > > classpath.
> > > Depending on the order is not recommended.
> > >
> > > I think Cedric's idea was to roll your own ISRL that knows exactly
> where
> > is
> > > your resource bundle and knows how to load it.
> > >
> > >
> > > On Mon, Jun 24, 2013 at 10:16 AM, Marios Skounakis 
> > > wrote:
> > >
> > > > Not sure if this is what you mean but in Application.init I replaced
> > the
> > > > InitializerStringResourceLoader in
> > > > application.getResourceSettings().getStringResourceLoaders() with my
> > own
> > > > MyInitializerStringResourceLoader which resorts the initializers list
> > and
> > > > puts my own initializer in the first position.
> > > >
> > > > It works.
> > > >
> > > > Thanks
> > > >
> > > >
> > > > On Mon, Jun 24, 2013 at 9:09 AM, Cedric Gatay 
> > wrote:
> > > >
> > > > > Hi,
> > > > > You can write your own IStringResourceLoader providing your set of
> > > > > translations and register it in front of the list through the
> > > > IInitializer
> > > > > mechanism.
> > > > >
> > > > > Regards,
> > > > > Le 24 juin 2013 07:12, "Marios Skounakis"  a
> > écrit :
> > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I am developing a "framework" library with wicket components and
> > > > utility
> > > > > > classes that is intended to be reused in all wicket apps
> developed
> > by
> > > > our
> > > > > > company. I wish to override some of the standard wicket messages
> > > (e.g.
> > > > > > wicket-extensions datatable.no-records-found=No Records Found).
> > > > > >
> > > > > > I have created an Initializer class and a Initializer.properties
> > file
> > > > > with
> > > > > > the overriden messages. However wicket seems to first load the
> > > > > > wicket-extensions property file and then my own, perhaps due to
> > their
> > > > > > alphabetic order.
> > > > > >
> > > > > > Is there a way to specify the order in which Initilizers run? If
> > not,
> > > > is
> > > > > > there another way to override some of the wicket messages in a
> > place
> > > > that
> > > > > > can be reused across multiple applications (i.e. not in
> > > > > > WicketApplication.properties or a component/page properties
> file).
> > > > > >
> > > > > > Thanks
> > > > > > Marios
> > > > > >
> > > > >
> > > >
> > >
> >
>


Re: Javascript confirm with condition before submit

2013-06-24 Thread Marios Skounakis
Yeah, my example is wicket 6. I believe (I may be wrong though) that the
logic is the same in 1.5.7 you just need to adapt the method calls.


On Mon, Jun 24, 2013 at 11:06 AM, grignette  wrote:

> It doesn't work.
>
> You call commitBehavior.getCallbackScript() but :
>
> Multiple markers at this line
> - The method add(Component...) in the type AjaxRequestTarget is not
> applicable for the arguments
>  (CharSequence)
> - The method getCallbackScript() from the type
> AbstractDefaultAjaxBehavior
> is not visible
>
> I use Wicket 1.5.7. Do you think that is the problem ?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Javascript-confirm-with-condition-before-submit-tp4659672p4659722.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: IInitializer order

2013-06-24 Thread Marios Skounakis
Martin,

What I meant is that now I have my own
class MyInitializerStringResourceLoader extends
InitializerStringResourceLoader

and its constructor calls

super(sort(initializers));

and sort() puts my own Initializer first in the initializers list. Is this
not safe? It does seem to work (whereas before it wasn't working).


On Mon, Jun 24, 2013 at 10:20 AM, Martin Grigorov wrote:

> The order of the initializers depends on the order of the jars in the
> classpath.
> Depending on the order is not recommended.
>
> I think Cedric's idea was to roll your own ISRL that knows exactly where is
> your resource bundle and knows how to load it.
>
>
> On Mon, Jun 24, 2013 at 10:16 AM, Marios Skounakis 
> wrote:
>
> > Not sure if this is what you mean but in Application.init I replaced the
> > InitializerStringResourceLoader in
> > application.getResourceSettings().getStringResourceLoaders() with my own
> > MyInitializerStringResourceLoader which resorts the initializers list and
> > puts my own initializer in the first position.
> >
> > It works.
> >
> > Thanks
> >
> >
> > On Mon, Jun 24, 2013 at 9:09 AM, Cedric Gatay  wrote:
> >
> > > Hi,
> > > You can write your own IStringResourceLoader providing your set of
> > > translations and register it in front of the list through the
> > IInitializer
> > > mechanism.
> > >
> > > Regards,
> > > Le 24 juin 2013 07:12, "Marios Skounakis"  a écrit :
> > >
> > > > Hi all,
> > > >
> > > > I am developing a "framework" library with wicket components and
> > utility
> > > > classes that is intended to be reused in all wicket apps developed by
> > our
> > > > company. I wish to override some of the standard wicket messages
> (e.g.
> > > > wicket-extensions datatable.no-records-found=No Records Found).
> > > >
> > > > I have created an Initializer class and a Initializer.properties file
> > > with
> > > > the overriden messages. However wicket seems to first load the
> > > > wicket-extensions property file and then my own, perhaps due to their
> > > > alphabetic order.
> > > >
> > > > Is there a way to specify the order in which Initilizers run? If not,
> > is
> > > > there another way to override some of the wicket messages in a place
> > that
> > > > can be reused across multiple applications (i.e. not in
> > > > WicketApplication.properties or a component/page properties file).
> > > >
> > > > Thanks
> > > > Marios
> > > >
> > >
> >
>


Re: IInitializer order

2013-06-24 Thread Marios Skounakis
Not sure if this is what you mean but in Application.init I replaced the
InitializerStringResourceLoader in
application.getResourceSettings().getStringResourceLoaders() with my own
MyInitializerStringResourceLoader which resorts the initializers list and
puts my own initializer in the first position.

It works.

Thanks


On Mon, Jun 24, 2013 at 9:09 AM, Cedric Gatay  wrote:

> Hi,
> You can write your own IStringResourceLoader providing your set of
> translations and register it in front of the list through the IInitializer
> mechanism.
>
> Regards,
> Le 24 juin 2013 07:12, "Marios Skounakis"  a écrit :
>
> > Hi all,
> >
> > I am developing a "framework" library with wicket components and utility
> > classes that is intended to be reused in all wicket apps developed by our
> > company. I wish to override some of the standard wicket messages (e.g.
> > wicket-extensions datatable.no-records-found=No Records Found).
> >
> > I have created an Initializer class and a Initializer.properties file
> with
> > the overriden messages. However wicket seems to first load the
> > wicket-extensions property file and then my own, perhaps due to their
> > alphabetic order.
> >
> > Is there a way to specify the order in which Initilizers run? If not, is
> > there another way to override some of the wicket messages in a place that
> > can be reused across multiple applications (i.e. not in
> > WicketApplication.properties or a component/page properties file).
> >
> > Thanks
> > Marios
> >
>


IInitializer order

2013-06-23 Thread Marios Skounakis
Hi all,

I am developing a "framework" library with wicket components and utility
classes that is intended to be reused in all wicket apps developed by our
company. I wish to override some of the standard wicket messages (e.g.
wicket-extensions datatable.no-records-found=No Records Found).

I have created an Initializer class and a Initializer.properties file with
the overriden messages. However wicket seems to first load the
wicket-extensions property file and then my own, perhaps due to their
alphabetic order.

Is there a way to specify the order in which Initilizers run? If not, is
there another way to override some of the wicket messages in a place that
can be reused across multiple applications (i.e. not in
WicketApplication.properties or a component/page properties file).

Thanks
Marios


Re: Javascript confirm with condition before submit

2013-06-21 Thread Marios Skounakis
Here is the basic solution. I believe you can expand on this.

public class ServerSideConfirmationExamplePage extends WebPage {

Person person; // needs to be serializable

public ServerSideConfirmationExamplePage() {
this(new Person());
}

public ServerSideConfirmationExamplePage(Person p) {
person = p;
Form form = new Form("form",
new CompoundPropertyModel(person));
add(form);
form.add(new TextField("firstName", String.class)
.setRequired(true));
form.add(new TextField("lastName", String.class)
.setRequired(true));

final AbstractDefaultAjaxBehavior commitBehavior = new
AbstractDefaultAjaxBehavior() {

@Override
protected void respond(AjaxRequestTarget target) {
// user has confirmed (see below onSubmit)
try {
// here we would update the database, e.g.
// personManager.update(person);
target.appendJavaScript("alert('Person "
+ person.getFirstName() + " "
+ person.getLastName() + " saved!');");
// or perhaps, setResponsePage(...)
} catch (Exception e) {
// show exception message here
// perhaps
// form.error("Unexpected error");
// or target.appendJavascript("alert('unexpected
error');");
}
}
};
add(commitBehavior);

form.add(new AjaxButton("submit") {
@Override
public void onSubmit(AjaxRequestTarget target, Form frm) {
// validations have run and person has been updated with
the user's input
// we show the confirmation now
// and call the commitBehavior's callback script upon user
confirmation
target.appendJavaScript("if (confirm('are you sure you want
to save "
+ person.getFirstName()
+ " "
+ person.getLastName()
+ "?')) {" + commitBehavior.getCallbackScript() +
"}");
}
});
}
}


On Sat, Jun 22, 2013 at 12:55 AM, grignette  wrote:

> I like your solution with 3 issues :
>
> /Usually I override onSubmit (either on the form or the ajax button) and
> return the confirmation there. If the user confirms, I follow up with
> another ajax call which actually commits the data./
>
> If you can give me more details, i will be verry happy !
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Javascript-confirm-with-condition-before-submit-tp4659672p4659688.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: Javascript confirm with condition before submit

2013-06-21 Thread Marios Skounakis
Also this approach assumes that your form is not using a
LoadableDetachableModel but it's using a serializable domain object which
can be used to store the data the user posted via the form between the
first ajax call (submit) and the second ajax call (confirmation) which
needs to save them to the db.

Perhaps if you use an AjaxFormSubmitBehavior instead of an
AbstractDefaultAjaxBehavior you can repost the form data after user
confirmation and avoid the need to store them in a serializable domain
object. I haven't tried this.


On Sat, Jun 22, 2013 at 12:46 AM, Marios Skounakis  wrote:

> I personally like server side confirmations because they can be customized
> based on the submitted data and you can use the model to customize the
> confirmation. If you do it client side you need to do it in javascript and
> using the component's values which is in my opinion ugly.
>
> Usually I override onSubmit (either on the form or the ajax button) and
> return the confirmation there. If the user confirms, I follow up with
> another ajax call which actually commits the data.
>
> This method has the following issues which you must take into
> consideration:
> 1. Because the confirmation is shown onSubmit, all validations happen
> before the confirmation. If a component is invalid, processing stops before
> the confirmation is shown. Also the form model has been updated. This may
> or may not be a problem. If you are in a regular database app, this is okay
> as long as your don't actually update the database.
> 2. Triggering a second ajax call after the user confirms is a bit tricky.
> You need to add an AbstractDefaultAjaxBehavior to the page and call it's
> getCallbackScript() if the user confirms. Then do the actual commit (e.g.
> store to the db) in it's respond() method.
> 3. Also this approach requires an extra ajax call to actually commit the
> form.
>
> I sometimes do confirmations using wicket's ModalWindow (or my own
> alternative JQuery-based implementation). This allows me to have a
> consistent presentation for all modal dialogs, be it confirmation,
> information or input dialogs. Also, using a ModalWindow allows for easier
> implementation of issue (2) above as instead of using an
> AbstractDefaultAjaxBehavior you can use the ModalWindow's CloseCallback to
> do the actual commit.
>
> There are other ways to do (2) above, such as having an extra ajax
> button/link that you trigger by javascript if the user confirms and use
> it's onSubmit method to actually commit the form.
>
> The above is a rather condensed version of what you need to do, let me
> know if you are interested and I can provide more details.
>
>
> On Sat, Jun 22, 2013 at 12:06 AM, grignette wrote:
>
>> Thanks for your answer.
>>
>> I'am sorry but I don't like the first solution. The second is better I
>> think
>> but I have 6 or 7 rules to implement like that. So it can be difficult.
>>
>> Someone have an other idea ? If no, I will try to implement the second
>> solution...
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Javascript-confirm-with-condition-before-submit-tp4659672p4659682.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: Javascript confirm with condition before submit

2013-06-21 Thread Marios Skounakis
I personally like server side confirmations because they can be customized
based on the submitted data and you can use the model to customize the
confirmation. If you do it client side you need to do it in javascript and
using the component's values which is in my opinion ugly.

Usually I override onSubmit (either on the form or the ajax button) and
return the confirmation there. If the user confirms, I follow up with
another ajax call which actually commits the data.

This method has the following issues which you must take into consideration:
1. Because the confirmation is shown onSubmit, all validations happen
before the confirmation. If a component is invalid, processing stops before
the confirmation is shown. Also the form model has been updated. This may
or may not be a problem. If you are in a regular database app, this is okay
as long as your don't actually update the database.
2. Triggering a second ajax call after the user confirms is a bit tricky.
You need to add an AbstractDefaultAjaxBehavior to the page and call it's
getCallbackScript() if the user confirms. Then do the actual commit (e.g.
store to the db) in it's respond() method.
3. Also this approach requires an extra ajax call to actually commit the
form.

I sometimes do confirmations using wicket's ModalWindow (or my own
alternative JQuery-based implementation). This allows me to have a
consistent presentation for all modal dialogs, be it confirmation,
information or input dialogs. Also, using a ModalWindow allows for easier
implementation of issue (2) above as instead of using an
AbstractDefaultAjaxBehavior you can use the ModalWindow's CloseCallback to
do the actual commit.

There are other ways to do (2) above, such as having an extra ajax
button/link that you trigger by javascript if the user confirms and use
it's onSubmit method to actually commit the form.

The above is a rather condensed version of what you need to do, let me know
if you are interested and I can provide more details.


On Sat, Jun 22, 2013 at 12:06 AM, grignette  wrote:

> Thanks for your answer.
>
> I'am sorry but I don't like the first solution. The second is better I
> think
> but I have 6 or 7 rules to implement like that. So it can be difficult.
>
> Someone have an other idea ? If no, I will try to implement the second
> solution...
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Javascript-confirm-with-condition-before-submit-tp4659672p4659682.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: Ajax form submit and Tomcat maxPostSize/connectionTimeout

2013-06-21 Thread Marios Skounakis
Martin,

Thank you for your replies. You are right that using
MultipartServletWebRequestImpl you can set the max size and handle the
error.

Cheers
Marios


On Fri, Jun 21, 2013 at 2:09 PM, Martin Grigorov wrote:

> On Fri, Jun 21, 2013 at 12:29 PM, Marios Skounakis 
> wrote:
>
> > Looking at tomcat sources it seems tomcat does not throw an exception bug
> > simply logs a debug message!
> >
> > Regarding wicket now, setting Form#setMaxSize seems to have no effect
> > unless there is a file upload involved. My case has just lots of
> textareas
> > with lots of text content... Can you please confirm this?
> >
>
> Hm, yes and no.
> By default ServletWebRequest is used in WebApplication#newWebRequest().
> When there is FileUpload (multi part data) Wicket automatically switches to
> org.apache.wicket.protocol.http.servlet.MultipartServletWebRequestImpl (see
>
> org.apache.wicket.protocol.http.servlet.ServletWebRequest#newMultipartWebRequest).
> This request impl
> uses
> org.apache.wicket.protocol.http.servlet.MultipartServletWebRequestImpl.CountingInputStream
> to count *all* bytes. So it should work. Just setup MSWRI to be the default
> instead of SWR.
>
>
> >
> > So it seems there is no way to detect if the user has exceeded the max
> post
> > size. If they do, you get empty post data...
> >
> > I have considered a workaround: use a hidden field with a preset value,
> on
> > postback check that the post parameters include this preset value, throw
> > exception otherwise. What do you think?
> >
> >
> >
> > On Fri, Jun 21, 2013 at 12:48 PM, Martin Grigorov  > >wrote:
> >
> > > On Fri, Jun 21, 2013 at 11:44 AM, Marios Skounakis 
> > > wrote:
> > >
> > > > Actually I want to read the whole input, and increasing tomcat
> > > maxPostSize
> > > > is the solution.
> > > >
> > > > But I was puzzled by the fact that I got no exception and instead I
> got
> > > > this weird behavior. Is there something that wicket does that keeps
> > > tomcat
> > > > from throwing the exception?
> > > >
> > >
> > > No. As you see Wicket just tries to read the parameters map and it is
> > > empty.
> > > I guess there is Tomcat property that switches its behavior when
> reading
> > > huge POST data.
> > >
> > >
> > > >
> > > >
> > > >
> > > >
> > > > On Fri, Jun 21, 2013 at 12:32 PM, Martin Grigorov <
> > mgrigo...@apache.org
> > > > >wrote:
> > > >
> > > > > You can use Wicket API to set the maxSize -
> > > > > org.apache.wicket.markup.html.form.Form#setMaxSize
> > > > > This way Tomcat will read the whole input and Wicket will report
> the
> > > > error.
> > > > >
> > > > > But maybe reading the whole input is what you try to avoid.
> > > > >
> > > > >
> > > > > On Fri, Jun 21, 2013 at 11:24 AM, Marios Skounakis <
> msc...@gmail.com
> > >
> > > > > wrote:
> > > > >
> > > > > > Some more info after further investigation:
> > > > > >
> > > > > > The problem is definitely related to tomcat maxPostSize
> parameter.
> > I
> > > > have
> > > > > > set this to a very small value (100) and the problem is occurring
> > > even
> > > > in
> > > > > > very small regular (non ajax) form posts.
> > > > > >
> > > > > > Debugging this I found that
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.wicket.protocol.http.servlet.ServletWebRequest.generatePostParameters
> > > > > >
> > > > > > calls
> > > > > > Map params =
> > > getContainerRequest().getParameterMap();
> > > > > > and gets a blank params map.
> > > > > >
> > > > > > This explains the fact that the form is normally processed and
> > > rendered
> > > > > > with null component values.
> > > > > >
> > > > > > I am not sure how I can investigate this further.
> > > getContainerRequest()
> > > > > is
> > > > > > a tomcat RequestFacade object so this is where I stopped tracing
> > the
> > > > > > execution. Perhaps it's a tomcat bug. I'll go

Re: Ajax form submit and Tomcat maxPostSize/connectionTimeout

2013-06-21 Thread Marios Skounakis
Looking at tomcat sources it seems tomcat does not throw an exception bug
simply logs a debug message!

Regarding wicket now, setting Form#setMaxSize seems to have no effect
unless there is a file upload involved. My case has just lots of textareas
with lots of text content... Can you please confirm this?

So it seems there is no way to detect if the user has exceeded the max post
size. If they do, you get empty post data...

I have considered a workaround: use a hidden field with a preset value, on
postback check that the post parameters include this preset value, throw
exception otherwise. What do you think?



On Fri, Jun 21, 2013 at 12:48 PM, Martin Grigorov wrote:

> On Fri, Jun 21, 2013 at 11:44 AM, Marios Skounakis 
> wrote:
>
> > Actually I want to read the whole input, and increasing tomcat
> maxPostSize
> > is the solution.
> >
> > But I was puzzled by the fact that I got no exception and instead I got
> > this weird behavior. Is there something that wicket does that keeps
> tomcat
> > from throwing the exception?
> >
>
> No. As you see Wicket just tries to read the parameters map and it is
> empty.
> I guess there is Tomcat property that switches its behavior when reading
> huge POST data.
>
>
> >
> >
> >
> >
> > On Fri, Jun 21, 2013 at 12:32 PM, Martin Grigorov  > >wrote:
> >
> > > You can use Wicket API to set the maxSize -
> > > org.apache.wicket.markup.html.form.Form#setMaxSize
> > > This way Tomcat will read the whole input and Wicket will report the
> > error.
> > >
> > > But maybe reading the whole input is what you try to avoid.
> > >
> > >
> > > On Fri, Jun 21, 2013 at 11:24 AM, Marios Skounakis 
> > > wrote:
> > >
> > > > Some more info after further investigation:
> > > >
> > > > The problem is definitely related to tomcat maxPostSize parameter. I
> > have
> > > > set this to a very small value (100) and the problem is occurring
> even
> > in
> > > > very small regular (non ajax) form posts.
> > > >
> > > > Debugging this I found that
> > > >
> > > >
> > >
> >
> org.apache.wicket.protocol.http.servlet.ServletWebRequest.generatePostParameters
> > > >
> > > > calls
> > > > Map params =
> getContainerRequest().getParameterMap();
> > > > and gets a blank params map.
> > > >
> > > > This explains the fact that the form is normally processed and
> rendered
> > > > with null component values.
> > > >
> > > > I am not sure how I can investigate this further.
> getContainerRequest()
> > > is
> > > > a tomcat RequestFacade object so this is where I stopped tracing the
> > > > execution. Perhaps it's a tomcat bug. I'll go ahead and try with
> > > different
> > > > tomcat versions.
> > > >
> > > >
> > > >
> > > >
> > > > On Fri, Jun 21, 2013 at 10:40 AM, Martin Grigorov <
> > mgrigo...@apache.org
> > > > >wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > >
> > > > > On Thu, Jun 20, 2013 at 10:11 PM, Marios Skounakis <
> msc...@gmail.com
> > >
> > > > > wrote:
> > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I have the following problem:
> > > > > > - User submits form with lots of textareas via ajax
> > > > > > - User gets a blank page
> > > > > >
> > > > > > I think (but I'm not quite sure yet) this happens when the
> > textareas
> > > > > > contain so much text that either maxPostSize or connectionTimeout
> > > > (submit
> > > > > > tries to store to db as well) are exceeded.
> > > > > >
> > > > > > The weird thing is that there is no exception. The form comes
> back
> > > > after
> > > > > > the ajax request with blank components.
> > > > > >
> > > > >
> > > > > So is it a blank page or just form elements without values ?
> > > > >
> > > > >
> > > > > >
> > > > > > Has anyone else seen this behavior? Why is there no exception?
> > > > > >
> > > > >
> > > > > If the problem is maxSize then there must be an exception. This
> will
> > > lead
> > > > > to onFailure() call executed in Ajax request.
> > > > >
> > > > >
> > > > > >
> > > > > > Thanks
> > > > > > Marios
> > > > > >
> > > > >
> > > >
> > >
> >
>


Re: Ajax form submit and Tomcat maxPostSize/connectionTimeout

2013-06-21 Thread Marios Skounakis
Actually I want to read the whole input, and increasing tomcat maxPostSize
is the solution.

But I was puzzled by the fact that I got no exception and instead I got
this weird behavior. Is there something that wicket does that keeps tomcat
from throwing the exception?




On Fri, Jun 21, 2013 at 12:32 PM, Martin Grigorov wrote:

> You can use Wicket API to set the maxSize -
> org.apache.wicket.markup.html.form.Form#setMaxSize
> This way Tomcat will read the whole input and Wicket will report the error.
>
> But maybe reading the whole input is what you try to avoid.
>
>
> On Fri, Jun 21, 2013 at 11:24 AM, Marios Skounakis 
> wrote:
>
> > Some more info after further investigation:
> >
> > The problem is definitely related to tomcat maxPostSize parameter. I have
> > set this to a very small value (100) and the problem is occurring even in
> > very small regular (non ajax) form posts.
> >
> > Debugging this I found that
> >
> >
> org.apache.wicket.protocol.http.servlet.ServletWebRequest.generatePostParameters
> >
> > calls
> > Map params = getContainerRequest().getParameterMap();
> > and gets a blank params map.
> >
> > This explains the fact that the form is normally processed and rendered
> > with null component values.
> >
> > I am not sure how I can investigate this further. getContainerRequest()
> is
> > a tomcat RequestFacade object so this is where I stopped tracing the
> > execution. Perhaps it's a tomcat bug. I'll go ahead and try with
> different
> > tomcat versions.
> >
> >
> >
> >
> > On Fri, Jun 21, 2013 at 10:40 AM, Martin Grigorov  > >wrote:
> >
> > > Hi,
> > >
> > >
> > > On Thu, Jun 20, 2013 at 10:11 PM, Marios Skounakis 
> > > wrote:
> > >
> > > > Hi all,
> > > >
> > > > I have the following problem:
> > > > - User submits form with lots of textareas via ajax
> > > > - User gets a blank page
> > > >
> > > > I think (but I'm not quite sure yet) this happens when the textareas
> > > > contain so much text that either maxPostSize or connectionTimeout
> > (submit
> > > > tries to store to db as well) are exceeded.
> > > >
> > > > The weird thing is that there is no exception. The form comes back
> > after
> > > > the ajax request with blank components.
> > > >
> > >
> > > So is it a blank page or just form elements without values ?
> > >
> > >
> > > >
> > > > Has anyone else seen this behavior? Why is there no exception?
> > > >
> > >
> > > If the problem is maxSize then there must be an exception. This will
> lead
> > > to onFailure() call executed in Ajax request.
> > >
> > >
> > > >
> > > > Thanks
> > > > Marios
> > > >
> > >
> >
>


Re: Ajax form submit and Tomcat maxPostSize/connectionTimeout

2013-06-21 Thread Marios Skounakis
Some more info after further investigation:

The problem is definitely related to tomcat maxPostSize parameter. I have
set this to a very small value (100) and the problem is occurring even in
very small regular (non ajax) form posts.

Debugging this I found that
org.apache.wicket.protocol.http.servlet.ServletWebRequest.generatePostParameters

calls
Map params = getContainerRequest().getParameterMap();
and gets a blank params map.

This explains the fact that the form is normally processed and rendered
with null component values.

I am not sure how I can investigate this further. getContainerRequest() is
a tomcat RequestFacade object so this is where I stopped tracing the
execution. Perhaps it's a tomcat bug. I'll go ahead and try with different
tomcat versions.




On Fri, Jun 21, 2013 at 10:40 AM, Martin Grigorov wrote:

> Hi,
>
>
> On Thu, Jun 20, 2013 at 10:11 PM, Marios Skounakis 
> wrote:
>
> > Hi all,
> >
> > I have the following problem:
> > - User submits form with lots of textareas via ajax
> > - User gets a blank page
> >
> > I think (but I'm not quite sure yet) this happens when the textareas
> > contain so much text that either maxPostSize or connectionTimeout (submit
> > tries to store to db as well) are exceeded.
> >
> > The weird thing is that there is no exception. The form comes back after
> > the ajax request with blank components.
> >
>
> So is it a blank page or just form elements without values ?
>
>
> >
> > Has anyone else seen this behavior? Why is there no exception?
> >
>
> If the problem is maxSize then there must be an exception. This will lead
> to onFailure() call executed in Ajax request.
>
>
> >
> > Thanks
> > Marios
> >
>


Ajax form submit and Tomcat maxPostSize/connectionTimeout

2013-06-20 Thread Marios Skounakis
Hi all,

I have the following problem:
- User submits form with lots of textareas via ajax
- User gets a blank page

I think (but I'm not quite sure yet) this happens when the textareas
contain so much text that either maxPostSize or connectionTimeout (submit
tries to store to db as well) are exceeded.

The weird thing is that there is no exception. The form comes back after
the ajax request with blank components.

Has anyone else seen this behavior? Why is there no exception?

Thanks
Marios


Re: Paging and excessive database access (repeaters)

2013-06-11 Thread Marios Skounakis
This example is not quite optimized. The DetachableContactModel's
constructor is

public DetachableContactModel(Contact c)
{
this(c.getId());
}

but it should be:


public DetachableContactModel(Contact c)
{
this(c.getId());
setObject(c);
}

The way it's done in the example although the model is given the contact,
it stores only its id and needs to load it from the database in order to
access it, even while rendering the table. The way I suggest the model is
given the contact and does not need to load it.

So, the way it's done in the example database access is as follows:
- a list query to get the contacts for a given page
- n queries by id, one for each row

The way I'm suggesting database access is as follows:
- a list query to get the contacts for a give page
- no other queties

If the row contains say a link column that accesses the row model in the
ajax click, then you will see an additional database access by id when the
DetachableContactModel is attached.

Cheers
Marios


On Tue, Jun 11, 2013 at 6:56 PM, Daniel Watrous wrote:

> Hi,
>
> I'm following the example in the repeaters section for paging through large
> amounts of data:
>
> http://www.wicket-library.com/wicket-examples-6.0.x/repeater/wicket/bookmarkable/org.apache.wicket.examples.repeater.PagingPage
>
> Based on the example and how I've had to implement this there is a lot of
> data access. First is in the ContactDataProvider. The function iterator
> queries for the set of data that will be displayed.
>
> Next, all the objects that are returned need to be wrapped in
> a DetachableContactModel. The load mechanism here then loads each
> individual object from the datastore.
>
> In the example, the data is in memory. In a real world scenario the data is
> likely to be remote and this setup could have a significant performance
> impact.
>
> Is there some way to cut out some of the data access? For example, can I
> get rid of DetachableContactModel and just use the data retrieved through
> the ContactDataProvider?
>
> Thanks,
> Daniel
>


Reusing behaviors across components

2013-06-10 Thread Marios Skounakis
Hi all,

Is there any obvious reason why adding the same behavior instance that
implements onBeforeRender and onAfterRender cannot be used on multiple
components on the same form?

Thanks
Marios


Re: Making FormComponents read only on and off

2013-05-30 Thread Marios Skounakis
Carl-Eric,

A subtle problem with this approach is that you don't have direct access to
the embedded control's properties or to its markup.

So for instance you need an extra non-standard way for adding behaviors to
the embedded component (e.g. implement an addBehaviorToComponent method to
the panel so it's add() remains unchanged in case you need it), or you need
to do something like panel.getEmbeddedComponent().add(behavior). Also you
cannot subclass the embedded component.

Alternatively you can go the ViewOrEdit approach which takes the component
as a constructor argument so you have direct access to it and you can also
subclass it.

However in both cases you don't have access to the component's markup since
it's embedded in the FormComponentPanel's markup and you need to rely on
AttributeModifiers.

Overall this approach is ok but it does make the actual component less
reachable. This is why I am considering doing this via a behavior as it
changes nothing with respect to the way you treat the component.

Marios


On Thu, May 30, 2013 at 5:12 PM, Carl-Eric Menzel wrote:

> This is exactly where I'd use a custom component. Basically like you
> said something with both a Label (that you can make pretty with CSS)
> and a TextField (for when it's enabled) - yes, it adds a little
> verbosity, but if you put that in custom reusable component (subclass
> FormComponentPanel to do that), you have that only once and then can
> cleanly use that everywhere else.
>
> Carl-Eric
>
> On Thu, 30 May 2013 16:29:56 +0300
> Marios Skounakis  wrote:
>
> > Hi all,
> >
> > I have what seems a rather common requirement: to be able to switch
> > form components to read-only mode on and off in ajax updates.
> >
> > The simple and clear solutions is to use the enabled property, but
> > this results in ugly disabled controls in the browser. And you can't
> > really handle this via css consistently last I ckecked.
> >
> > I would much prefer a solution where disabled controls are rendered
> > as read only textboxes (let's disregard checkboxes and radiobuttons
> > for a moment). Again the obvious solution is to add an extra
> > TextField for each component and toggle the paired components'
> > visibility on and off. But this results in a lot of
> > unnecessary/boilerplate code in both the code and the markup files.
> >
> > Or you can use Panels that wrap FormComponents like ViewOrEdit does,
> > but again this adds verbosity to the form code.
> >
> > So is there any beautiful solution to this problem? What do people do?
> >
> > I have considered using a BorderBehavior or an
> > AbstractTransformerBehavior to add the html markup to render a read
> > only input control for disabled components and also hide the original
> > component by wrapping it in a span with visibility:hidden style.
> > BorderBehavior needs some modifications to work with ajax (implement
> > IAjaxRegionMarkupIdProvider) and to use dynamically generated markup
> > (to conditionally do nothing or add the extra markup to show the
> > description of the component's value) but it seems it can be done.
> > This seems like a rather pretty solution as it requires no extra
> > markup, and does not mess with the java code (you simply need to add
> > the behavior to the components).
> >
> > Any feedback would be greatly appreciated.
> > Marios
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Making FormComponents read only on and off

2013-05-30 Thread Marios Skounakis
Hi all,

I have what seems a rather common requirement: to be able to switch form
components to read-only mode on and off in ajax updates.

The simple and clear solutions is to use the enabled property, but this
results in ugly disabled controls in the browser. And you can't really
handle this via css consistently last I ckecked.

I would much prefer a solution where disabled controls are rendered as read
only textboxes (let's disregard checkboxes and radiobuttons for a moment).
Again the obvious solution is to add an extra TextField for each component
and toggle the paired components' visibility on and off. But this results
in a lot of unnecessary/boilerplate code in both the code and the markup
files.

Or you can use Panels that wrap FormComponents like ViewOrEdit does, but
again this adds verbosity to the form code.

So is there any beautiful solution to this problem? What do people do?

I have considered using a BorderBehavior or an AbstractTransformerBehavior
to add the html markup to render a read only input control for disabled
components and also hide the original component by wrapping it in a span
with visibility:hidden style. BorderBehavior needs some modifications to
work with ajax (implement IAjaxRegionMarkupIdProvider) and to use
dynamically generated markup (to conditionally do nothing or add the extra
markup to show the description of the component's value) but it seems it
can be done. This seems like a rather pretty solution as it requires no
extra markup, and does not mess with the java code (you simply need to add
the behavior to the components).

Any feedback would be greatly appreciated.
Marios


Re: Wicket and tomcat cluster

2013-03-29 Thread Marios Skounakis
Thanks, things are a lot clearer for me now.


On Fri, Mar 29, 2013 at 4:28 PM, Dan Retzlaff  wrote:

> If you go non-sticky you'll need to experiment with RenderStrategy. Each
> has it's pros and cons, and I don't have experience to advise you further.
>
> Yes if you want the user to interact with more than one page at a time
> you'll need to make sure they're all available. You'll also need to
> replicate synchronously to all nodes.
>
> Since Wicket is a stateful framework, it's simply not well-suited to
> nonsticky deployment IMO, and you should just enable stickiness. In the off
> chance of a server failure user loses some page history, but at least they
> stay logged in and don't lose their current activity.
>
> I've wondered at possibility of replication listener on failover nodes that
> maintains complete local disk page store. Not sure if/which containers
> provide such hooks.
>
> Dan
> On Mar 29, 2013 1:06 AM, "Marios Skounakis"  wrote:
>
> > Dan, thanks for you answer.
> >
> > As you said, with the default implementation of DiskDataStore only the
> most
> > recent page is kept in the session state and available on all servers. So
> > are using non-sticky sessions and having a stateful page open a modal
> > window with a new stateful page will not work. Correct?
> >
> >
> >
> > On Thu, Mar 28, 2013 at 10:37 PM, Dan Retzlaff 
> > wrote:
> >
> > > Sorry I mistyped: default is REDIRECT_TO_BUFFER.
> > >
> > > On Thu, Mar 28, 2013 at 2:36 PM, Dan Retzlaff 
> > wrote:
> > >
> > > > Hi Marios,
> > > >
> > > > This behavior is determined by IDataStore interface. DiskDataStore is
> > > used
> > > > by default, so only the most recent page is kept in the session (and
> > > > available for failover). It puts page history into a directory
> > specified
> > > in
> > > > "javax.servlet.context.tempdir" servlet attribute (under "work"
> > directory
> > > > in Tomcat). If you want more page history available on failover,
> > specify
> > > a
> > > > IPageManagerProvider in your Application#init() that constructs
> > > > HttpSessionDataStore instead. Note HttpSessionDataStore's
> > > > IDataStoreEvictionStrategy dependency which keeps session usage under
> > > > control.
> > > >
> > > > If Wicket clustering is new to you, also note that Wicket
> > > > uses RenderStrategy.REDIRECT_TO_RENDER by default. See javadoc for
> > > details,
> > > > but in short: you should configure your load balancer for sticky
> > > sessions.
> > > >
> > > > Dan
> > > >
> > > > On Thu, Mar 28, 2013 at 2:17 PM, Marios Skounakis  > > >wrote:
> > > >
> > > >> Hi all,
> > > >>
> > > >> I
> > > >> 'm planning to setup a terracotta tomcat cluster. The wicket site
> > claims
> > > >> that "all Wicket applications will work on a cluster automatically
> and
> > > >> without additional work
> > > >> "
> > > >> .
> > > >>
> > > >> I understand that basically since session state is kept in
> > serializable
> > > >> objects within the http session, it mostly works.
> > > >>
> > > >> But is it true that NO changes are needed? Do I need to change any
> > > >> settings? What does the page store do once it has to push a page
> from
> > > >> memory to disk?
> > > >>
> > > >>
> > > >> T
> > > >> hanks in advance
> > > >> Marios
> > > >>
> > > >
> > > >
> > >
> >
>


Re: Wicket and tomcat cluster

2013-03-29 Thread Marios Skounakis
Dan, thanks for you answer.

As you said, with the default implementation of DiskDataStore only the most
recent page is kept in the session state and available on all servers. So
are using non-sticky sessions and having a stateful page open a modal
window with a new stateful page will not work. Correct?



On Thu, Mar 28, 2013 at 10:37 PM, Dan Retzlaff  wrote:

> Sorry I mistyped: default is REDIRECT_TO_BUFFER.
>
> On Thu, Mar 28, 2013 at 2:36 PM, Dan Retzlaff  wrote:
>
> > Hi Marios,
> >
> > This behavior is determined by IDataStore interface. DiskDataStore is
> used
> > by default, so only the most recent page is kept in the session (and
> > available for failover). It puts page history into a directory specified
> in
> > "javax.servlet.context.tempdir" servlet attribute (under "work" directory
> > in Tomcat). If you want more page history available on failover, specify
> a
> > IPageManagerProvider in your Application#init() that constructs
> > HttpSessionDataStore instead. Note HttpSessionDataStore's
> > IDataStoreEvictionStrategy dependency which keeps session usage under
> > control.
> >
> > If Wicket clustering is new to you, also note that Wicket
> > uses RenderStrategy.REDIRECT_TO_RENDER by default. See javadoc for
> details,
> > but in short: you should configure your load balancer for sticky
> sessions.
> >
> > Dan
> >
> > On Thu, Mar 28, 2013 at 2:17 PM, Marios Skounakis  >wrote:
> >
> >> Hi all,
> >>
> >> I
> >> 'm planning to setup a terracotta tomcat cluster. The wicket site claims
> >> that "all Wicket applications will work on a cluster automatically and
> >> without additional work
> >> "
> >> .
> >>
> >> I understand that basically since session state is kept in serializable
> >> objects within the http session, it mostly works.
> >>
> >> But is it true that NO changes are needed? Do I need to change any
> >> settings? What does the page store do once it has to push a page from
> >> memory to disk?
> >>
> >>
> >> T
> >> hanks in advance
> >> Marios
> >>
> >
> >
>


Wicket and tomcat cluster

2013-03-28 Thread Marios Skounakis
Hi all,

I
'm planning to setup a terracotta tomcat cluster. The wicket site claims
that "all Wicket applications will work on a cluster automatically and
without additional work
"
.

I understand that basically since session state is kept in serializable
objects within the http session, it mostly works.

But is it true that NO changes are needed? Do I need to change any
settings? What does the page store do once it has to push a page from
memory to disk?


T
hanks in advance
Marios


Re: Wicket Ajax Debug Errors - how to debug?

2013-03-17 Thread Marios Skounakis
Did so - WICKET-5104 <https://issues.apache.org/jira/browse/WICKET-5104>

I still don't understand what the problem is. Despite the error things seem
to be working. Is it safe to ignore it, or should I find a workaround until
it is fixed?


On Sat, Mar 16, 2013 at 8:53 AM, Sven Meier  wrote:

> Seems like this is caused by WICKET-4959.
>
> Please file a Jira issue.
>
> Sven
>
>
> On 03/15/2013 09:56 PM, Marios Skounakis wrote:
>
>> Hi all,
>>
>> I am using a modal window as a substitute for messageboxes. E.g. I have a
>> few forms with an ajax submit button, and I am using the modal window to
>> first display a confirmation message, and if the user accepts it, to
>> display a success / failure message.
>>
>> I am getting frequent errors in the Wicket Ajax Debug console. One is:
>> *
>> ERROR: *
>>
>> Wicket.Ajax.Call.**processEvaluation: Exception evaluating javascript:
>> TypeError: Wicket.TimerHandles is undefined, text:
>> (function(){clearTimeout(**Wicket.TimerHandles['**spinner21e']); delete
>> Wicket.TimerHandles['**spinner21e'];})();
>>
>> The spinner control mentioned above is an image component with an
>> AbstractAjaxTimerBehavior. In all cases of error, it has
>> setVisibilityAllowed(false) (it's hidden).
>>
>> Usually the errors can be ignored and the page still functions normally.
>>
>> I've never really dug into the way ajax responses are handled so I'm not
>> sure where to start in order to track this error down.
>>
>> Any ideas?
>> Thanks in advance,
>> Marios
>>
>>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Wicket Ajax Debug Errors - how to debug?

2013-03-15 Thread Marios Skounakis
Hi all,

I am using a modal window as a substitute for messageboxes. E.g. I have a
few forms with an ajax submit button, and I am using the modal window to
first display a confirmation message, and if the user accepts it, to
display a success / failure message.

I am getting frequent errors in the Wicket Ajax Debug console. One is:
*
ERROR: *
Wicket.Ajax.Call.processEvaluation: Exception evaluating javascript:
TypeError: Wicket.TimerHandles is undefined, text:
(function(){clearTimeout(Wicket.TimerHandles['spinner21e']); delete
Wicket.TimerHandles['spinner21e'];})();

The spinner control mentioned above is an image component with an
AbstractAjaxTimerBehavior. In all cases of error, it has
setVisibilityAllowed(false) (it's hidden).

Usually the errors can be ignored and the page still functions normally.

I've never really dug into the way ajax responses are handled so I'm not
sure where to start in order to track this error down.

Any ideas?
Thanks in advance,
Marios


Re: Ajax Behavior not working after 1 time

2013-03-14 Thread Marios Skounakis
Yes it is. What Martin says will fix your problem.


On Thu, Mar 14, 2013 at 9:35 PM, eugenebalt  wrote:

> Martin, we're already doing setOutputMarkupId(true) on both dropdowns. Is
> that one different from OutputMarkupId?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Ajax-Behavior-not-working-after-1-time-tp4657254p4657257.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
>
>


Image.initModel() returns null and forbids attaching an image to a form CompoundPropertyModel - why?

2013-03-14 Thread Marios Skounakis
Hi all,

I have created a component that extends NonCachingImage which overrides
getImageResource(). The intent was to include this in a form, and retrieve
the image data from a property of the form object.

However this does not work because Image.initModel() returns null and as a
result my component does not get an AttachedPropertyModel.

If I override initModel in my component and replicate the code from
Component.initModel it work perfectly. But this is ugly (duplicate code,
etc).

So, any suggestions?

Thanks in advance,
Marios


Re: Form with multiple AjaxButton - why are all onEvent() called?

2013-02-06 Thread Marios Skounakis
You probably want to override onSubmit and not onEvent.  onEvent is for
handling events sent by the event mechanism, not for handling clicks...



On Wed, Feb 6, 2013 at 1:28 PM, Ondrej Zizka  wrote:

> Hi all,
>
> With Wicket 1.5.9,
> I have a form with
>
> 
> 
> Form form = new Form("form");
> add(form);
> // Logging tests
> form.add( new AjaxButton("log1"){
> @Override public void onEvent(IEvent event) { log.info("1");
> }
> }.setOutputMarkupId(true));
> form.add( new AjaxButton("log2"){
> @Override public void onEvent(IEvent event) { log.info("2");
> }
> }.setOutputMarkupId(true));
> ...
>
> When any is clicked, all onEvent() are called.
> Why does that happen? How should I make it react only to the clicked
> button?
>
> Thanks,
> Ondra
>
> The generated code is:
>
>
> http://localhost:**8080/essc-portal/admin?1-2.**
> IFormSubmitListener-form
> >"id="**form4"method="post"><**input
>  type="hidden"name="form4_hf_0"**id="form4_hf_0"/>
> 
> 
>
>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Problem with markup inheritance in Wicket 6

2013-02-05 Thread Marios Skounakis
Understood. I am still unclear why wicket would behave differently in
deployment and development configuration with respect to missing components
in the markup. Is there any actual use case for this? If not, I believe it
would be better to have a consistent behavior.

Of course, changing the way deployment configuration behaves currently
could break working apps who are now functional because an exception is not
being thrown...



On Mon, Feb 4, 2013 at 9:50 PM, Paul Bors  wrote:

> If your web.xml specifies configuration=deployment and you want to report
> the runtime error on a custom page then in your Application class:
>
> protected void init() {
>   ...
>   getApplicationSettings().setInternalErrorPage(MyInternalErrorPage.class);
>   ...
> }
>
> class MyInternalErrorPage extend WebPage {
>   public MyInternalErrorPage() {
> Session.get().error("Some custom generic error");
> throw new RestartResponseException( Application.get().getHomePage() );
>   }
> }
>
> Also, do you have  in your parent HTML file and
>  in your extended markup file?
>
> https://cwiki.apache.org/WICKET/wickets-xhtml-tags.html#Wicket%2527sXHTMLtags-Elementwicket%253Aextend
> https://cwiki.apache.org/WICKET/markup-inheritance.html
>
> But if this was working for you in 5.x then I presume you do have the
> markup inheritence setup right.
>
> ~ Thank you,
>Paul Bors
> On Sat, Feb 2, 2013 at 3:52 PM, Marios Skounakis  wrote:
>
> > I've seen this happen too. It's not related to inheritance. If you add a
> > component in code and omit it in the html file, you get different
> behavior
> > in the following cases:
> >
> > - if your web.xml specifies configuration=deployment, you don't get an
> > error
> > - if you web.xml specifies configuration=development, you get a runtime
> > exception
> >
> >
> > On Fri, Feb 1, 2013 at 3:29 PM, Martin Grigorov  > >wrote:
> >
> > > Hi,
> > >
> > > I think there are no changes in this area.
> > > Do you extend/inherit the markup or completely override it ?
> > > I expect to see  instead of  in
> > > MyNewPanel.html.
> > > Create a quickstart and attach it to a ticket in Jira please.
> > >
> > >
> > > On Fri, Feb 1, 2013 at 2:12 PM, Dmitriy Neretin <
> > > dmitriy.nere...@googlemail.com> wrote:
> > >
> > > > Hi Folks,
> > > >
> > > > I have another problem during Wicket 6 migration. This time it is a
> > > problem
> > > > with markup inheritance.
> > > >
> > > > I have an old wicket panel and appropriate markup file:
> > > > MyOldGoodWicketPanel & MyOldGoodWicketPanel.html
> > > >
> > > > Markup file looks like this:
> > > >
> > > > 
> > > >  ... stuff ...
> > > > 
> > > >
> > > > Some months ago I needed for the same Panel another Markup, so what I
> > > did:
> > > >
> > > > class MyNewPanel extends MyOldGoodWicketPanel {
> > > > almost the same stuff
> > > > }
> > > >
> > > > and an appropriate markup file:
> > > >
> > > > MyNewPanel.html with following markup:
> > > >
> > > > 
> > > >  ... other stuff ...
> > > > 
> > > >
> > > > It worked pretty well in the Wicket 1.5, but now I get Exceptions,
> that
> > > the
> > > > components from the super class (MyOldGoodWicketPanel) are not found
> in
> > > the
> > > > subclass/ in the markup file of the sublclass...
> > > >
> > > > Can somebody explain me what happened?
> > > >
> > > > Regards,
> > > > Dmitriy
> > > >
> > >
> > >
> > >
> > > --
> > > Martin Grigorov
> > > jWeekend
> > > Training, Consulting, Development
> > > http://jWeekend.com <http://jweekend.com/>
> > >
> >
>


Re: Problem with markup inheritance in Wicket 6

2013-02-02 Thread Marios Skounakis
I've seen this happen too. It's not related to inheritance. If you add a
component in code and omit it in the html file, you get different behavior
in the following cases:

- if your web.xml specifies configuration=deployment, you don't get an error
- if you web.xml specifies configuration=development, you get a runtime
exception


On Fri, Feb 1, 2013 at 3:29 PM, Martin Grigorov wrote:

> Hi,
>
> I think there are no changes in this area.
> Do you extend/inherit the markup or completely override it ?
> I expect to see  instead of  in
> MyNewPanel.html.
> Create a quickstart and attach it to a ticket in Jira please.
>
>
> On Fri, Feb 1, 2013 at 2:12 PM, Dmitriy Neretin <
> dmitriy.nere...@googlemail.com> wrote:
>
> > Hi Folks,
> >
> > I have another problem during Wicket 6 migration. This time it is a
> problem
> > with markup inheritance.
> >
> > I have an old wicket panel and appropriate markup file:
> > MyOldGoodWicketPanel & MyOldGoodWicketPanel.html
> >
> > Markup file looks like this:
> >
> > 
> >  ... stuff ...
> > 
> >
> > Some months ago I needed for the same Panel another Markup, so what I
> did:
> >
> > class MyNewPanel extends MyOldGoodWicketPanel {
> > almost the same stuff
> > }
> >
> > and an appropriate markup file:
> >
> > MyNewPanel.html with following markup:
> >
> > 
> >  ... other stuff ...
> > 
> >
> > It worked pretty well in the Wicket 1.5, but now I get Exceptions, that
> the
> > components from the super class (MyOldGoodWicketPanel) are not found in
> the
> > subclass/ in the markup file of the sublclass...
> >
> > Can somebody explain me what happened?
> >
> > Regards,
> > Dmitriy
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com 
>


Re: Multiple select drop down in Wicket

2013-01-15 Thread Marios Skounakis
I've considered using select2 (it looks very impressive) but I was put off
by the fact that its appearance is not consistent with the rest of the input
controls.

How do people solve this?


On Tue, Jan 15, 2013 at 6:34 PM, Paul Bors  wrote:

> I gave up on the normal select in HTML and started to use Igor's Select2.
>
> See http://ivaynberg.github.com/select2/
>
> ~ Thank you,
>   Paul Bors
>
> -Original Message-
> From: kshitiz [mailto:k.agarw...@gmail.com]
> Sent: Monday, January 14, 2013 9:17 PM
> To: users@wicket.apache.org
> Subject: RE: Multiple select drop down in Wicket
>
> Actually ListMultipleChoice is not that user friendly as compare to multi
> select drop down. Thats why I preferred the later one. Is there any way to
> implement the same in Wicket?
>
>
>
> --
> View this message in context:
>
> http://apache-wicket.1842946.n4.nabble.com/Multiple-select-drop-down-in-Wick
> et-tp4655355p4655368.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: What is the wicket 6 equivalent of ComponentRequestTarget?

2012-12-14 Thread Marios Skounakis
Thanks for the prompt reply Martin. I'm not migrating, I just found this
code on the net and wanted to use it. Point taken though, I should look in
the migration notes first...


On Wed, Dec 12, 2012 at 12:00 PM, Martin Grigorov wrote:

> cycle.scheduleRequestHandlerAfterCurrent(new ComponentRenderingRequestHandl
> er(...))
>
> This API has changed with Wicket 1.5. You may want to read its migration
> page since you migrate from older version directly to Wicket 6
>
>
> On Wed, Dec 12, 2012 at 10:51 AM, Marios Skounakis 
> wrote:
>
> > Hi all,
> >
> > I found this old code:
> >
> > getRequestCycle().setRequestTarget(new
> ComponentRequestTarget(dataTable));
> > WebResponse wr = (WebResponse) getResponse();
> > wr.setContentType("application/vnd.ms-excel; charset=UTF-8");
> > wr.setCharacterEncoding("UTF-8");
> > wr.setHeader("content-disposition", "attachment;filename=excel.xls");
> >
> > I understand all the drawbacks of getting the HTML from a data table and
> > disguise it as an excel file, but I have a similar use case that I want
> do
> > get and return the markup of a single component.
> >
> > The above code contains classes and methods that have been removed. Can
> > someone please provide the wicket 6 equivalent of the above?
> >
> > Thanks
> > Marios
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>


Re: How important is detaching models really ?

2012-11-27 Thread Marios Skounakis
Hi Colin,

I find I am in agreement with your points about lazy loaded parts of the
data model and how this can be simplified if you use LDMs.

However, if you use LDMs for edit pages, you need to deal with concurrency
issues yourself. You cannot rely on Hibernate's optimistic concurrency
mechanism (version). Because every time your LDM fetches a fresh instance
of the entity, you can never have a StaleObjectException. Dealing with
concurrency yourself may be as easy as keeping the version property in addition
to the Id property in the LDM, and checking against it when re-attaching
the model, but this does add some complexity to the application code.

Any thoughts on this?

Cheers
Marios



On Wed, Nov 28, 2012 at 2:10 AM, Colin Rogers <
colin.rog...@objectconsulting.com.au> wrote:

> Tobias,
>
> I also find it's really important when using Hibernate. Hibernate is a
> total dog unless all your fetches are Lazy (so you only load what you
> need). With any UI, you load your entity and display a certain amount, but
> based on user action, you might need lazy loaded dependencies - with a
> loadable detachable model, the main entity is always 'fresh' in the session
> and lazily loaded dependencies are always available. It means everything in
> your data can be specified to be lazy loaded. Your data model is clean,
> your UI is clean.
>
> In other UIs frameworks, or when I've used Wicket without LDMs, I spend
> half my time dealing with Lazy Load Exceptions, or having to pre-load
> certain lazy loaded entities for certain screens, that may or may not ever
> be used. You end up changing your data model to fit your UI (ugh!) or
> having tons of duplicated, effectively redundant, UI specific service
> methods (ugh!).
>
> Cheers,
> Col.
>
> -Original Message-
> From: Chris Colman [mailto:chr...@stepaheadsoftware.com]
> Sent: Friday, 23 November 2012 12:53 AM
> To: users@wicket.apache.org
> Subject: RE: How important is detaching models really ?
>
> I guess in more complex apps the UI elements end up with lots of
> references to model objects so detaching does save a lot of memory and it
> also makes transferring session data from one web server to another (if
> required) in a multi server environment, much more efficient. I have
> experienced the result of accidentally serializing an object graph with
> megabytes of data that didn't use detach - ouch!
>
> The other benefit of detaching is your model will expose updates to the UI
> (if a redisplay occurred) that were made in other ORM sessions (depending
> on your ORM). Keeping a non detached copy of the model object will
> typically be like caching it in it's current state for most ORMs - i.e. it
> can get stale
>
> >-Original Message-
> >From: tobi [mailto:tobias.gie...@code-sourcery.de]
> >Sent: Thursday, 22 November 2012 9:10 PM
> >To: users@wicket.apache.org
> >Subject: How important is detaching models really ?
> >
> >Hi guys,
> >
> > From my understanding & experiments with Wicket's built-in session
> >inspector , detaching models seems to just affect the size of the page
> >store (and of course cut-down the amount of I/O required for
> serializing
> >the object graph). The session size shown on my pages is a constantly
> >low value (<1k , we're storing nothing except the currently logged-in
> >user).
> >
> >So it *seems* not detaching models has no effect on the (long-term)
> >memory footprint of a Wicket application.
> >
> >According to
> >https://cwiki.apache.org/WICKET/working-with-wicket-models.html , not
> >detaching models should affect the session size but at least looking at
> >the inspector I can't see this. Is the wiki article still correct / the
> >inspector not telling the truth ?
> >
> >Thanks,
> >Tobias
> >
> >P.S. I'm using Wicket 1.5.8 btw
> >
> >-
> >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
>
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and may also contain copyright or privileged material. If you are not the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are those
> of the individual sender and should not be relied upon as the considered
> view, opinion, conclusions, advice or statement of this company except
> where the sender expressly, and with authority, states them to be the
> considered view, opinion, conclusions, advice or stat

AuthenticatedWebSession and remember me problem

2012-10-10 Thread Marios Skounakis
Hi all,

I am using Wicket 1.5.8 with wicket-auth and I can across the following
problem.

I have implemented a MyWebSession extends AuthenticatedWebSession with my
own authentication, and a login page with the default loginpanel with the
remember option enabled.

All of my pages are showing the logged on user's username on the top right,
fetched by MyWebSession.get().getUsername()

Now, if a user has saved their credentials (remember me), and they try to
access a private page without logging in, the user is redirected to the
login page, they are automatically authenticated by the cookie, and then
redirected to the original page. Their username is correctly shown on the
top right.

However, if the user accesses an unprotected page, their username is not
shown on the top right, because wicket does not try to authenticate the
user via the login page. Even adding a component with
@AuthorizeAction(action=Action.Render) to the page did not cause the user
to be authenticated.

To fix this, I had to copy the following code from LoginPanel to
MyWebSession's constructor:

IAuthenticationStrategy authenticationStrategy =
getApplication().getSecuritySettings().getAuthenticationStrategy();
// get username and password from persistence store
String[] data = authenticationStrategy.load();

if ((data != null) && (data.length > 1)) {
if (!signIn(data[0], data[1])) {
authenticationStrategy.remove();
}
}

Two questions:
1) Is this the right approach to do this?
2) Shouldn't this be the default behavior or at least a behavior that can
be activated on the AuthenticatedWebSession without having to explicitly
add code to call wicket-auth internals?

Thanks in advance,
Marios


Usage of PageReference

2012-09-26 Thread Marios Skounakis
Hi all,

I've recently started using wicket. I'm still examining the various ways to
do things in order to decide how to go about and implement the UI.

I've noticed (trial and error) that if you have a modal window with a page
content, it's not possible to pass values between the originating and the
modal page by passing page objects around. It seems that you can do it by
using PageReferences though.

Could someone explain what is the different between passing a page object
and a PageReference and when one should use a PageReference?

On a related note, I tried to extend a ModalWindow so that the subclass
contains an extra field (result), but this does not seem to be accessible
in the close handler (actually it can be accessed but its value has been
reset). Any ideas?

Thanks
Marios