Re: Dynamic resources and ajax calls

2015-06-04 Thread Edgar Merino
Hello, thanks for the response, what do you mean exactly by delegate to 
the mounted resource? I'm thinking I can mount the images resource, and 
simply reference them using their URI (is this what you mean by delating 
the call to the mounted resource?), so even if users replace the panel, 
image loading won't be cancelled, since it will still be waiting for an 
existing resource (instead of the problem I'm having now, where the 
resource vanishes before being transfered to the user).


I believe this should avoid 3. in your response, what do you think?

On 04/06/15 02:26, Ernesto Reinaldo Barreiro wrote:

Hi,

I see two options

1- Block the screen while images are being loaded so user has to wait.

or

1- Mount a resource serving images thumbnails.
2- Panel showing those thumbnails just delegates into mounted resource. So,
image generation will be faster and panel replacement will be more fluid
3- Also block UI while replacing panel: if your users are too fast you
might encounter the same problem again.


On Thu, Jun 4, 2015 at 9:16 AM, Edgar Merino donvo...@gmail.com wrote:


Hello:

 I'm having a problem with dynamic resources and ajax calls, I have a
panel that includes some image thumbnails, these thumbnails may take
between 5 and 30 seconds, if a user attemps to cancel loading of this
images and loading another panel (e.g. replacing the panel), an exception
will be thrown and cause a 500 response for each of the resources that
failed to load. The logged error message is as follows:

ERROR - DefaultExceptionMapper - Unexpected error occurred
org.apache.wicket.WicketRuntimeException: Component
'mainContainer:mainPanel:wrappedContent:tabbedPanel:panel:materias' has
been removed from page.

 I understand the error, but I don't know what to do to avoid it, has
anyone got a similar problem and found a solution?


Thanks in advance.
Edgar Merino.

-
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



Dynamic resources and ajax calls

2015-06-04 Thread Edgar Merino

Hello:

I'm having a problem with dynamic resources and ajax calls, I have 
a panel that includes some image thumbnails, these thumbnails may take 
between 5 and 30 seconds, if a user attemps to cancel loading of this 
images and loading another panel (e.g. replacing the panel), an 
exception will be thrown and cause a 500 response for each of the 
resources that failed to load. The logged error message is as follows:


ERROR - DefaultExceptionMapper - Unexpected error occurred
org.apache.wicket.WicketRuntimeException: Component 
'mainContainer:mainPanel:wrappedContent:tabbedPanel:panel:materias' has 
been removed from page.


I understand the error, but I don't know what to do to avoid it, 
has anyone got a similar problem and found a solution?



Thanks in advance.
Edgar Merino.

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



Re: Dynamic resources and ajax calls

2015-06-04 Thread Edgar Merino

Thank you both, I'll work on this per your suggestions.


On 04/06/15 03:10, Martin Grigorov wrote:

On Thu, Jun 4, 2015 at 11:04 AM, Ernesto Reinaldo Barreiro 
reier...@gmail.com wrote:


@Martin,

Yes I mean exactly that... And if you are clever enough you can do some
optimizations like caching generated thumbnails :-)


I am not so clever so I'd let the browser and the CDN (if there is such) do
that do for me ;-)
I'll just make sure the path to the image is stable and the respective
response headers are set.



On Thu, Jun 4, 2015 at 10:00 AM, Martin Grigorov mgrigo...@apache.org
wrote:


I think Ernesto suggests to use something like the mounted resources
explained at
http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/
This way the browser will be able to make several requests to the server
because there is no locking at the server side as with Page instances.

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

On Thu, Jun 4, 2015 at 10:43 AM, Edgar Merino donvo...@gmail.com

wrote:

Hello, thanks for the response, what do you mean exactly by delegate to
the mounted resource? I'm thinking I can mount the images resource, and
simply reference them using their URI (is this what you mean by

delating

the call to the mounted resource?), so even if users replace the panel,
image loading won't be cancelled, since it will still be waiting for an
existing resource (instead of the problem I'm having now, where the
resource vanishes before being transfered to the user).

I believe this should avoid 3. in your response, what do you think?


On 04/06/15 02:26, Ernesto Reinaldo Barreiro wrote:


Hi,

I see two options

1- Block the screen while images are being loaded so user has to wait.

or

1- Mount a resource serving images thumbnails.
2- Panel showing those thumbnails just delegates into mounted

resource.

So,
image generation will be faster and panel replacement will be more

fluid

3- Also block UI while replacing panel: if your users are too fast you
might encounter the same problem again.


On Thu, Jun 4, 2015 at 9:16 AM, Edgar Merino donvo...@gmail.com

wrote:

  Hello:

  I'm having a problem with dynamic resources and ajax calls, I

have a

panel that includes some image thumbnails, these thumbnails may take
between 5 and 30 seconds, if a user attemps to cancel loading of this
images and loading another panel (e.g. replacing the panel), an

exception

will be thrown and cause a 500 response for each of the resources

that

failed to load. The logged error message is as follows:

ERROR - DefaultExceptionMapper - Unexpected error occurred
org.apache.wicket.WicketRuntimeException: Component
'mainContainer:mainPanel:wrappedContent:tabbedPanel:panel:materias'

has

been removed from page.

  I understand the error, but I don't know what to do to avoid it,

has

anyone got a similar problem and found a solution?


Thanks in advance.
Edgar Merino.

-
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





--
Regards - Ernesto Reinaldo Barreiro




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



Re: AbstractDefaultAjaxBehavior and getCallbackScript

2014-07-02 Thread Edgar Merino
Thank you Martin, we ended up doing the ajax call in a semi-manual way: 
we are still using PackageTextTemplate but this time we are only passing 
the AjaxRequestAttributes and declaring them as an object in js, that 
way we can add extra paremeters that are dynamically generated right 
from javascript.



Thanks again for the response.

On 02/07/14 00:55, Martin Grigorov wrote:

Hi,

Using #updateAjaxAttributes() is the recommended way.
You can add:
-  extra parameters - their values are know when the callback script is
being generated
- dynamic extra parameters - their values are dynamically calculated just
before the Ajax call is done

But as you may see at other places you can also use the JavaScript APIs to
make a call to the server ad-hoc. The main thing you should know/have it
the destination url.


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


On Tue, Jul 1, 2014 at 10:15 PM, Edgar Merino donvo...@gmail.com wrote:


Hello, we've been working on some javascript code that needs to compute
some values before sending the request to wicket server side. Currently, we
bind directly to the component's click event using jquery from js, and send
the request using Wicket.Ajax.post function. To pass the needed variables
to make the ajax call (e.g. callbackUrl) from java to js we are using
PackageTextTemplate.

Everything works fine, but then I saw lots of examples using
getCallbackScript, and they modify the AjaxRequestAttributes through the
AbstractDefaultAjaxBehavior#updateAjaxAttributes() method to pass extra
parameters that need to be sent with the request.

I believe both approaches would work, but updating the
AjaxRequestAttributes seems the best way to go... am I missing something
here?


Thanks in advance.
Edgar Merino.

-
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



AbstractDefaultAjaxBehavior and getCallbackScript

2014-07-01 Thread Edgar Merino
Hello, we've been working on some javascript code that needs to compute 
some values before sending the request to wicket server side. Currently, 
we bind directly to the component's click event using jquery from js, 
and send the request using Wicket.Ajax.post function. To pass the needed 
variables to make the ajax call (e.g. callbackUrl) from java to js we 
are using PackageTextTemplate.


Everything works fine, but then I saw lots of examples using 
getCallbackScript, and they modify the AjaxRequestAttributes through the 
AbstractDefaultAjaxBehavior#updateAjaxAttributes() method to pass extra 
parameters that need to be sent with the request.


I believe both approaches would work, but updating the 
AjaxRequestAttributes seems the best way to go... am I missing something 
here?



Thanks in advance.
Edgar Merino.

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



Re: PageParameters refresh on page reload

2014-05-22 Thread Edgar Merino
Thanks for the response Martin, good to know this is fixed in v7 (and 
the workaround for v6).



On 21/05/14 14:08, Martin Grigorov wrote:

Hi,

This is fixed in Wicket 7.x. We didn't apply the fix to 6.x because it is a
behavior change.
You can read the current parameters in #onConfigure() with
getRequestCycle().getRequest().getRequestParameters() and override with
them the page's parameters (page.getPageParameters())

Martin Grigorov
Wicket Training and Consulting


On Wed, May 21, 2014 at 9:41 PM, Edgar Merino donvo...@gmail.com wrote:


Hello, I've got a problem that I've just noticed today: When an instance
of a WebPage is created with some url parameters, the PageParameters object
is never updated, that is, if I refresh the same webpage with different url
parameters this won't be taken into account, instead the first params used
to create the WebPage are used. Is there a way to have url parameters
updated on each page request?

Thanks in advance.

-
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



PageParameters refresh on page reload

2014-05-21 Thread Edgar Merino
Hello, I've got a problem that I've just noticed today: When an instance 
of a WebPage is created with some url parameters, the PageParameters 
object is never updated, that is, if I refresh the same webpage with 
different url parameters this won't be taken into account, instead the 
first params used to create the WebPage are used. Is there a way to have 
url parameters updated on each page request?


Thanks in advance.

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



AjaxFormComponentUpdatingBehavior attached to parent

2014-05-05 Thread Edgar Merino
Hello, I currently have a Panel with a DropDownChoice added to it, 
currently I have a method (MyPanel#addBehavior()) to delegate adding 
behaviors to the DDD, but I would like to know if it would be possible 
to attach the behavior to the Panel instead of the DDD. Is such thing 
possible?



Thanks in advance.
Edgar Merino

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



Re: AjaxFormComponentUpdatingBehavior attached to parent

2014-05-05 Thread Edgar Merino
Ah! Never though of doing that, I just realized that add(Behavior...) 
method is not final, I don't know where I saw that the signature for 
this and add(Component...) was final


Thanks for the help!

On 05/05/14 14:45, Sven Meier wrote:
No, the AjaxFormComponentUpdatingBehavior has to be added to the 
formComponent.


Your custom Panel can override add(Behavior...) to do the forwarding 
though.


Sven

On 05/05/2014 08:19 PM, Edgar Merino wrote:
Hello, I currently have a Panel with a DropDownChoice added to it, 
currently I have a method (MyPanel#addBehavior()) to delegate adding 
behaviors to the DDD, but I would like to know if it would be 
possible to attach the behavior to the Panel instead of the DDD. Is 
such thing possible?



Thanks in advance.
Edgar Merino

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




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




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



Re: How to handle dependent properties with FormComponents

2014-01-30 Thread Edgar Merino

Thank you.

On 28/11/13 01:58, Martin Grigorov wrote:

Hi,

See AbstractFormValidator.
Use any of the provided implementations of this class as inspiration.


On Thu, Nov 28, 2013 at 9:48 AM, Edgar Merino donvo...@gmail.com wrote:


Hello, I have a class that defines 2 properties that depend on each other
(start and end dates). Currently, I have to provide getters and setters for
this properties and then call a validator method inside
Form#onValidateModelObjects(). It would be preferable to just provide the
getters and a single method to set and validate the 2 dependent properties.

Is there a way to accomplish this?
Thanks in advance.
Edgar Merino

-
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



How to handle dependent properties with FormComponents

2013-11-27 Thread Edgar Merino
Hello, I have a class that defines 2 properties that depend on each 
other (start and end dates). Currently, I have to provide getters and 
setters for this properties and then call a validator method inside 
Form#onValidateModelObjects(). It would be preferable to just provide 
the getters and a single method to set and validate the 2 dependent 
properties.


Is there a way to accomplish this?
Thanks in advance.
Edgar Merino

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



Problems with FileUploadFile and CompoundPropertyModels

2013-10-25 Thread Edgar Merino
Hello, I'm having a problem with a FileUploadField, I'm using 
CompoundPropertyModels through my application but for this single 
element I would like to avoid having a model, however calling 
fileUploadField.setDefauiltModel(null) will not work, since it will 
always try to locate a CompoundPropertyModel, is there a way to avoid this?


Thanks in advance.

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



Re: Problems with FileUploadFile and CompoundPropertyModels

2013-10-25 Thread Edgar Merino
It seems that overriding Component#initModel() to return null does the 
trick!


On 25/10/13 12:30, Edgar Merino wrote:
Hello, I'm having a problem with a FileUploadField, I'm using 
CompoundPropertyModels through my application but for this single 
element I would like to avoid having a model, however calling 
fileUploadField.setDefauiltModel(null) will not work, since it will 
always try to locate a CompoundPropertyModel, is there a way to avoid 
this?


Thanks in advance.



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



Re: Problems with FileUploadFile and CompoundPropertyModels

2013-10-25 Thread Edgar Merino
Thank you Francois, but as I mentioned in an earlier post overriding 
FileUploadField#initModel() to return null did the trick and seems a bit 
cleaner that creating a Dummy model. Overriding initModel() makes sure 
the model won't be looked up in the component parents.



Edgar Merino

On 25/10/13 13:03, Francois Meillet wrote:

FileUploadField needs a model which implements IModelListFileUpload

have a look to these threads

http://apache-wicket.1842946.n4.nabble.com/file-upload-in-nested-form-with-CPM-needs-dummy-model-td4660468.html
http://apache-wicket.1842946.n4.nabble.com/AW-file-upload-in-nested-form-with-CPM-needs-dummy-model-td4660609.html


François Meillet
Formation Wicket - Développement Wicket





Le 25 oct. 2013 à 19:30, Edgar Merino donvo...@gmail.com a écrit :


Hello, I'm having a problem with a FileUploadField, I'm using 
CompoundPropertyModels through my application but for this single element I 
would like to avoid having a model, however calling 
fileUploadField.setDefauiltModel(null) will not work, since it will always try 
to locate a CompoundPropertyModel, is there a way to avoid this?

Thanks in advance.

-
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



Handle form submit Exception on setDefaultModelObject

2013-09-10 Thread Edgar Merino
Hello, I have a Form with some components attached to it, when I submit 
the Form through an AjaxSubmitLink some of these components may throw an 
Exception while updating their models. What can I do to handle these 
Exceptions and show error messages using error() and adding the feedback 
panel to the AJaxRequestTarget, instead of showing wicket's default 
Exception page (or internal error when in production mode)?



Thanks in advance.
Edgar

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



Re: Handle form submit Exception on setDefaultModelObject

2013-09-10 Thread Edgar Merino
Overriding Form#process(IFormSubmitter) suffices my needs, thanks for 
the quick response.



On 10/09/13 07:01, Sven Meier wrote:

A) override Form#process(IFormSubmitter) and handle the exception
B) implement an IRequestCycleListener which handles the exception

Sven

On 09/10/2013 01:46 PM, Edgar Merino wrote:
Hello, I have a Form with some components attached to it, when I 
submit the Form through an AjaxSubmitLink some of these components 
may throw an Exception while updating their models. What can I do to 
handle these Exceptions and show error messages using error() and 
adding the feedback panel to the AJaxRequestTarget, instead of 
showing wicket's default Exception page (or internal error when in 
production mode)?



Thanks in advance.
Edgar

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




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




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



Re: Custom FormComponent and model update

2013-09-04 Thread Edgar Merino
I managed to got it working, but in the end I gave up trying to 
integrate my js library and did it using pure wicket, the end result was 
a lot nicer and much easier to maintain.


Thank you for your answer.

On 30/08/13 03:09, Martin Grigorov wrote:

Hi,

There is a special handling for Ajax requests - the page is marked as dirty
and stored, but its pageId is not incremented. So the new state completely
overrides the old in the store.

By the object is not attached to a Form I understand that you try to
update the model of a Component which is not in the page's component tree.
Since this component is not visible/reachable by the page then its stateful
behavior is not reachable too. So at the end the page may be still
stateless and thus never stored.
Try with: page.setStatelessHint(false)


On Fri, Aug 30, 2013 at 8:22 AM, Edgar Merino donvo...@gmail.com wrote:


I'm completely lost here, I've been debugging AjaxCheckBox just to see how
it manages to not make the page dirty, but something strange happens when
calling Component#dirty(boolean) on Component#modelChanging(), I set a
breakpoint in the beginning of the Component#dirty(boolean) method but it
never gets there... although it is being called by Component#dirty().
However, when using my custom FormComponent, it will always mark the page
as dirty (it will enter the method) making my changes to be visible only on
the next version of the page, which is not what I want, any idea how to
solve this?




On 29/08/13 23:05, Edgar Merino wrote:


Found the problem, it has to do with versioning of pages... my callback
is not changing the version number in the URL so everytime I refresh the
web page I'm retrieving the older version of the page. I'm gonna have to
work with AjaxRequestTarget in order to avoid this I guess.


On 29/08/13 22:52, Edgar Merino wrote:


I have track this down to the Component#modelChanging() method, it seems
that the actual modified page is not being stored in the session (perhaps
it has something to do with dirty pages?). I'm a bit lost here, any clue
would be appreciated.

Thank you.

On 29/08/13 14:33, Edgar Merino wrote:


Hello, I'm having a problem with a FormComponent I'm implementing, I'm
manually calling FormComponent#validate(), FormComponent#valid() and
FormComponent#updateModel() inside MyBehavior#onRequest() since the object
is not attached to a Form, I'm using a custom Behavior (MyBehavior, which
extends AbstractAjaxBehavior, I don't need any of the functionality
provided by AjaxDefaultAbstractBehavior), the model changes for this
request but every time a new request is handled I see the component still
uses the old model that was supposed to be replaced in the previous request.

By debugging the application I can see that everytime a new request is
handled, the FormComponent will look for the model in the Component#data
attribute array, which holds the initially set IModel and is never
changed... I don't have a clue on how to change this, I bet this is the key
to solve this, does anyone have a clue on how to do this?


Thanks in advance,
Edgar Merino.




--**--**-
To unsubscribe, e-mail: 
users-unsubscribe@wicket.**apache.orgusers-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



Custom FormComponent and model update

2013-08-29 Thread Edgar Merino
Hello, I'm having a problem with a FormComponent I'm implementing, I'm 
manually calling FormComponent#validate(), FormComponent#valid() and 
FormComponent#updateModel() inside MyBehavior#onRequest() since the 
object is not attached to a Form, I'm using a custom Behavior 
(MyBehavior, which extends AbstractAjaxBehavior, I don't need any of the 
functionality provided by AjaxDefaultAbstractBehavior), the model 
changes for this request but every time a new request is handled I see 
the component still uses the old model that was supposed to be replaced 
in the previous request.


By debugging the application I can see that everytime a new request is 
handled, the FormComponent will look for the model in the Component#data 
attribute array, which holds the initially set IModel and is never 
changed... I don't have a clue on how to change this, I bet this is the 
key to solve this, does anyone have a clue on how to do this?



Thanks in advance,
Edgar Merino.

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



Re: Custom FormComponent and model update

2013-08-29 Thread Edgar Merino
I have track this down to the Component#modelChanging() method, it seems 
that the actual modified page is not being stored in the session 
(perhaps it has something to do with dirty pages?). I'm a bit lost here, 
any clue would be appreciated.


Thank you.

On 29/08/13 14:33, Edgar Merino wrote:
Hello, I'm having a problem with a FormComponent I'm implementing, I'm 
manually calling FormComponent#validate(), FormComponent#valid() and 
FormComponent#updateModel() inside MyBehavior#onRequest() since the 
object is not attached to a Form, I'm using a custom Behavior 
(MyBehavior, which extends AbstractAjaxBehavior, I don't need any of 
the functionality provided by AjaxDefaultAbstractBehavior), the model 
changes for this request but every time a new request is handled I see 
the component still uses the old model that was supposed to be 
replaced in the previous request.


By debugging the application I can see that everytime a new request is 
handled, the FormComponent will look for the model in the 
Component#data attribute array, which holds the initially set IModel 
and is never changed... I don't have a clue on how to change this, I 
bet this is the key to solve this, does anyone have a clue on how to 
do this?



Thanks in advance,
Edgar Merino.



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



Re: Custom FormComponent and model update

2013-08-29 Thread Edgar Merino
Found the problem, it has to do with versioning of pages... my callback 
is not changing the version number in the URL so everytime I refresh the 
web page I'm retrieving the older version of the page. I'm gonna have to 
work with AjaxRequestTarget in order to avoid this I guess.



On 29/08/13 22:52, Edgar Merino wrote:
I have track this down to the Component#modelChanging() method, it 
seems that the actual modified page is not being stored in the session 
(perhaps it has something to do with dirty pages?). I'm a bit lost 
here, any clue would be appreciated.


Thank you.

On 29/08/13 14:33, Edgar Merino wrote:
Hello, I'm having a problem with a FormComponent I'm implementing, 
I'm manually calling FormComponent#validate(), FormComponent#valid() 
and FormComponent#updateModel() inside MyBehavior#onRequest() since 
the object is not attached to a Form, I'm using a custom Behavior 
(MyBehavior, which extends AbstractAjaxBehavior, I don't need any of 
the functionality provided by AjaxDefaultAbstractBehavior), the model 
changes for this request but every time a new request is handled I 
see the component still uses the old model that was supposed to be 
replaced in the previous request.


By debugging the application I can see that everytime a new request 
is handled, the FormComponent will look for the model in the 
Component#data attribute array, which holds the initially set IModel 
and is never changed... I don't have a clue on how to change this, I 
bet this is the key to solve this, does anyone have a clue on how to 
do this?



Thanks in advance,
Edgar Merino.





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



Re: Custom FormComponent and model update

2013-08-29 Thread Edgar Merino
I'm completely lost here, I've been debugging AjaxCheckBox just to see 
how it manages to not make the page dirty, but something strange happens 
when calling Component#dirty(boolean) on Component#modelChanging(), I 
set a breakpoint in the beginning of the Component#dirty(boolean) method 
but it never gets there... although it is being called by 
Component#dirty(). However, when using my custom FormComponent, it will 
always mark the page as dirty (it will enter the method) making my 
changes to be visible only on the next version of the page, which is not 
what I want, any idea how to solve this?




On 29/08/13 23:05, Edgar Merino wrote:
Found the problem, it has to do with versioning of pages... my 
callback is not changing the version number in the URL so everytime I 
refresh the web page I'm retrieving the older version of the page. I'm 
gonna have to work with AjaxRequestTarget in order to avoid this I guess.



On 29/08/13 22:52, Edgar Merino wrote:
I have track this down to the Component#modelChanging() method, it 
seems that the actual modified page is not being stored in the 
session (perhaps it has something to do with dirty pages?). I'm a bit 
lost here, any clue would be appreciated.


Thank you.

On 29/08/13 14:33, Edgar Merino wrote:
Hello, I'm having a problem with a FormComponent I'm implementing, 
I'm manually calling FormComponent#validate(), FormComponent#valid() 
and FormComponent#updateModel() inside MyBehavior#onRequest() since 
the object is not attached to a Form, I'm using a custom Behavior 
(MyBehavior, which extends AbstractAjaxBehavior, I don't need any of 
the functionality provided by AjaxDefaultAbstractBehavior), the 
model changes for this request but every time a new request is 
handled I see the component still uses the old model that was 
supposed to be replaced in the previous request.


By debugging the application I can see that everytime a new request 
is handled, the FormComponent will look for the model in the 
Component#data attribute array, which holds the initially set IModel 
and is never changed... I don't have a clue on how to change this, I 
bet this is the key to solve this, does anyone have a clue on how to 
do this?



Thanks in advance,
Edgar Merino.







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



Re: Syncing files with designers

2012-12-06 Thread Edgar Merino
Thanks again for the response. For the first part I had it already 
figured out, but having a concrete example is always helpful.


 We thought the same - but this not manageable with more than 50 files 
in one folder. So we decide to use folders - as already mentioned. 
Perhaps I'll write a tutorial...


How did you manage relative links in markup? With css resources it won't 
be a problem, the designers can add their resources using link 
href=../css/style.css/link and any relative url in it will 
translate to the right path, however this is not true for relative paths 
inside the html document: img src=../img/img.png / for example, will 
be a problem since wicket always resolves relatives paths from the web 
root (or webapp folder).


Do you include the resources you need inside all of your folders so 
relative paths resolve correctly outside and inside the wicket application?



Thanks in advance,
Edgar Merino


On 05/12/12 10:56, Jan Riehn wrote:

Hello Edgar,

 I think I'm missing something: since every WebPage in wicket has 
straight access to resources located in the web root  (that is, every 
path reference in the page's markup is relative to the web root)


Wicket is able to locate resources outside of the web application: 
This could be done by implementing an own IResourceFinder:


public final class FileSystemResourceFinder implements IResourceFinder {
private final Resource resource;

public FileSystemResourceFinder(Resource resource) {
this.resource = resource;
}

@Override
public IResourceStream find(Class? clazz, String pathname) {
try {
final File file = new File(resource.getFile(), pathname);
if (file.exists()) {
return new FileResourceStream(file);
}
} catch (final IOException e) {
// ignore, file couldn't be found
}
return null;
}
}

At least you've to add the resource finder to the resource finders 
list with getResourceSettings().setResourceFinders(resourceFinderList) 
in your applications init method. Alternatively, implement a custom 
ResourceStreamLocator. At first the Locator should use the 
FileSystemResourceFinder - if there's no match the locator should 
fallback to wicket's default resource finder. So far, your application 
is able to locate resources from the local file system.


 I would like to avoid using folders to organise html files so the 
designers can put all the resources they need in their root folder. 
The mechanism you describe, seems to use folders, how are you managing 
this for the designers?


We thought the same - but this not manageable with more than 50 files 
in one folder. So we decide to use folders - as already mentioned. 
Perhaps I'll write a tutorial...



Best regards,

Jan


On 12/05/2012 02:49 PM, Edgar Merino wrote:
Hello Jan, that seems like a good approach. However, I think I'm 
missing something: since every WebPage in wicket has straight access 
to resources located in the web root (that is, every path reference 
in the page's markup is relative to the web root), I would like to 
avoid using folders to organize html files so the designers can put 
all the resources they need in their root folder. The mechanism you 
describe, seems to use folders, how are you managing this for the 
designers?



Edgar Merino


On 04/12/12 04:15, Jan Riehn wrote:

Hello Edgar,

Yes, this is how it works.

For the best separation of the responsibilities, you may store the 
resources outside of the web application (Think about a complete 
physical separation).
We've made a good experience to break-off with wicket's given 
package structure - wicket’s resource localization does not fit with 
a separation of the responsibilities: the web designer has no 
knowledge about the internal package structure and it's not 
resistant against refactoring. Therefore, we use a more technical 
mechanism based on style, variation locale and the filename.


1. prefix/style/variation/locale/filename.extension
2. prefix/style/variation/filename.extension
3. prefix/style/filename.extension
4. prefix/filename.extension
5. filename.extension


Best regards,

Jan

On 12/04/2012 09:04 AM, Edgar Merino wrote:

Hello, I would like our designers to work with a simple folder structure
on our application pages markup, and we would like to avoid including
java source code files with the files we share with them. What is the
best way to do this? I though about implementing a custom
ResourceStreamLocator, so I can for instance name our html files using
the fqcn e.g. my.company.HomePage.html and placing these files in the
default package (under src/main/html for example).

Is this the way to go?

Thanks in advance,
Edgar Merino

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











Re: Syncing files with designers

2012-12-05 Thread Edgar Merino
Hello Jan, that seems like a good approach. However, I think I'm missing 
something: since every WebPage in wicket has straight access to 
resources located in the web root (that is, every path reference in the 
page's markup is relative to the web root), I would like to avoid using 
folders to organize html files so the designers can put all the 
resources they need in their root folder. The mechanism you describe, 
seems to use folders, how are you managing this for the designers?



Edgar Merino


On 04/12/12 04:15, Jan Riehn wrote:

Hello Edgar,

Yes, this is how it works.

For the best separation of the responsibilities, you may store the 
resources outside of the web application (Think about a complete 
physical separation).
We've made a good experience to break-off with wicket's given package 
structure - wicket's resource localization does not fit with a 
separation of the responsibilities: the web designer has no knowledge 
about the internal package structure and it's not resistant against 
refactoring. Therefore, we use a more technical mechanism based on 
style, variation locale and the filename.


1. prefix/style/variation/locale/filename.extension
2. prefix/style/variation/filename.extension
3. prefix/style/filename.extension
4. prefix/filename.extension
5. filename.extension


Best regards,

Jan

On 12/04/2012 09:04 AM, Edgar Merino wrote:

Hello, I would like our designers to work with a simple folder structure
on our application pages markup, and we would like to avoid including
java source code files with the files we share with them. What is the
best way to do this? I though about implementing a custom
ResourceStreamLocator, so I can for instance name our html files using
the fqcn e.g. my.company.HomePage.html and placing these files in the
default package (under src/main/html for example).

Is this the way to go?

Thanks in advance,
Edgar Merino

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







Syncing files with designers

2012-12-04 Thread Edgar Merino
Hello, I would like our designers to work with a simple folder structure 
on our application pages markup, and we would like to avoid including 
java source code files with the files we share with them. What is the 
best way to do this? I though about implementing a custom 
ResourceStreamLocator, so I can for instance name our html files using 
the fqcn e.g. my.company.HomePage.html and placing these files in the 
default package (under src/main/html for example).


Is this the way to go?

Thanks in advance,
Edgar Merino

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



InputStreamResource

2009-08-10 Thread Edgar Merino
Hello, what would be the correct way to render an image (Resource) from 
an InputStream? Right now I've got a very simple extension of the 
Resource class (code below), but this is causing problems since 
InputStream is not serializable and I'm keeping a reference to it. 
Thanks in advance.


//CODE BEGINS

import java.io.InputStream;
import org.apache.wicket.Resource;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.AbstractResourceStream;

public class InputStreamResource extends Resource {

   private class InputStreamResourceStream extends AbstractResourceStream {

   public InputStream getInputStream() {
   return in;
   }

   public void close() {
   try {
   in.close();
   } catch (Exception e) {
   e.printStackTrace();
   }
   }
   }

   private InputStream in;

   public InputStreamResource(InputStream in) {
   this.in = in;
   }

   @Override
   public IResourceStream getResourceStream() {
   return new InputStreamResourceStream();
   }

}

//CODE ENDS


Edgar Merino

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



SessionPerRequestFilter

2009-02-04 Thread Edgar Merino

Hello,

   I'm implementing a j2ee filter to obtain a jcr session per http 
request (using a threadlocal), however it sometimes opens more than once 
session when I open a webpage, I'm thinking this is because many threads 
are involved in a single request, but this affects performance (a lot), 
what workaround can I apply to avoid this kind of overhead (to have a 
real session per request instead of session per thread?).


Correct me if I made the wrong assumptions,
Edgar Merino

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



File download

2009-01-07 Thread Edgar Merino

Hello,

   How can I allow a user to download a file from a stream? for example 
an xls that's generated when the user clicks a download button? where 
should I place the file to be downloaded?


Thanks in advance,
Edgar Merino

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



Re: Static injection not working (wicket-guice)

2008-10-23 Thread Edgar Merino
This one seems to have no answer, I've tried googling and everything 
stopped just here, were I started, I hope someone could provide a 
solution (different than using salve).


Edgar Merino




Edgar Merino escribió:

Anyone for this?


Edgar Merino escribió:

Hello,

   I've been trying to inject a service to some classes that are not 
wicket components, I've asked here and was suggested to use static 
injection: InjectorHolder.getInjector().inject(this); however this is 
not working with guice, I always get an illegalstateexception, 
injectorholder has not been assigned an injector. I've tried 
((GuiceInjectorHolder) 
(RequestCycle.get().getApplication().getMetaData(GuiceInjectorHolder.INJECTOR_KEY))).getInjector().injectMembers(this); 
however that gives me serialization problems, since wicket is not 
creating a proxy for my service. I'm on my way to give salve a try 
but I'm having some problems there too (waiting for a response from 
the Discussion group), what suggestions can you make?


Thanks in advance,
Edgar Merino







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trying to create a calendar - need some guidance

2008-10-23 Thread Edgar Merino
I've got an abstract calendar already coded, the only problem is that 
it's using a DataTable (instead of only a gridview), I have to change 
the code to use the gridview instead, I'll post the code tomorrow if 
I've got the time and you're still interested.


Edgar Merino





John Krasnay escribió:

Uh, yeah, that's what I meant to say, just use a GridView :-)

jk

On Thu, Oct 23, 2008 at 05:14:42PM -0700, Igor Vaynberg wrote:
  

all you need is a gridview. set columns to 7 and generate 30 items...

-igor

On Thu, Oct 23, 2008 at 1:47 PM, V. Jenks [EMAIL PROTECTED] wrote:


Hi all.

I'm trying to build a component-ized calendar that will be the centerpiece
of a new application I'm working on.  I built one this morning in JSP and
was able to do it with very little code.  I kept it simple and I'm hoping I
can retro-fit the logic into a wicket page cleanly, without too much
trouble.  I'm a little stuck because in my JSP, I simply loop through the
days and print until Saturday is reached, then I break to a new table row
and continue.  Doing this in Wicket seems tough because if I use a ListView,
I can't be as flexible as far as throwing in a new row while looping and
outputting table cells.

Here's the rough idea I came up with today in JSP, can someone give me some
pointers?

%@ page contentType=text/html pageEncoding=UTF-8 %
%@ page import=java.util.* %
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
%
 //get parameters to change date
 String monthParam = request.getParameter(month);
 String yearParam = request.getParameter(year);

 //create calendar object
 Calendar cal = Calendar.getInstance();
 cal.setFirstDayOfWeek(Calendar.SUNDAY); //set first day to Sunday

 if (monthParam != null)
   cal.set(Calendar.MONTH, (Integer.valueOf(monthParam)-1));

 if (yearParam != null)
   cal.set(Calendar.YEAR, Integer.valueOf(yearParam));

 //get total number of days in month
 int numDaysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);

 //get current month name in English
 String monthName = cal.getDisplayName(Calendar.MONTH, Calendar.LONG,
Locale.ENGLISH);

 //get current year
 int year = cal.get(Calendar.YEAR);

 //get array of day names
 String[] headers = {Sun, Mon, Tue, Wed, Thu, Fri, Sat};
%
html
 head
   meta http-equiv=Content-Type content=text/html; charset=UTF-8
   titleCalendarama!/title
 /head
 body
   table border=1
 tr
   !-- print month and year --
   th colspan=7 align=center%= monthName +   + year %/th
 /tr
 tr
   !-- loop and print days --
   %
 for (int i=0; i7; i++)
 {
   %
   td%= headers[i] %/td
   %
 }
   %
 /tr
 !-- DRAW CALENDAR --
 tr
   %
 for (int i=1; i=numDaysInMonth; i++)
 {
   //re-set calendar day in context of loop
   cal.set(Calendar.DAY_OF_MONTH, i);

   //get the day number of the week
   int day = cal.get(Calendar.DAY_OF_WEEK);

   //days without numbers count
   int blankDays = 0;

   //blank days before 1st of month?
   if (i == 1  day  1)
   {
 blankDays = day - i; //get count

 //loop through count and print blank day
 for (int x=1; x=blankDays; x++)
 {
   %
 td width=100 height=100nbsp;/td
   %
 }
   }
   %
 td width=100 height=100 valign=top%= i %/td
   %
   if (day == Calendar.SATURDAY)
   {
   %
 /tr
 tr
   %
   }

   //blank days after last day of month?
   if (i == numDaysInMonth  day  7)
   {
 blankDays = 7 - day; //get count

 //loop through count and print blank day
 for (int x=1; x=blankDays; x++)
 {
   %
 td width=100 height=100nbsp;/td
   %
 }
   }
 }
   %
 /tr
   /table
 /body
/html

--
View this message in context: 
http://www.nabble.com/Trying-to-create-a-calendar---need-some-guidance-tp20138860p20138860.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Static injection not working (wicket-guice)

2008-10-22 Thread Edgar Merino

Hello,

   I've been trying to inject a service to some classes that are not 
wicket components, I've asked here and was suggested to use static 
injection: InjectorHolder.getInjector().inject(this); however this is 
not working with guice, I always get an illegalstateexception, 
injectorholder has not been assigned an injector. I've tried 
((GuiceInjectorHolder) 
(RequestCycle.get().getApplication().getMetaData(GuiceInjectorHolder.INJECTOR_KEY))).getInjector().injectMembers(this); 
however that gives me serialization problems, since wicket is not 
creating a proxy for my service. I'm on my way to give salve a try but 
I'm having some problems there too (waiting for a response from the 
Discussion group), what suggestions can you make?


Thanks in advance,
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Static injection not working (wicket-guice)

2008-10-22 Thread Edgar Merino

Anyone for this?


Edgar Merino escribió:

Hello,

   I've been trying to inject a service to some classes that are not 
wicket components, I've asked here and was suggested to use static 
injection: InjectorHolder.getInjector().inject(this); however this is 
not working with guice, I always get an illegalstateexception, 
injectorholder has not been assigned an injector. I've tried 
((GuiceInjectorHolder) 
(RequestCycle.get().getApplication().getMetaData(GuiceInjectorHolder.INJECTOR_KEY))).getInjector().injectMembers(this); 
however that gives me serialization problems, since wicket is not 
creating a proxy for my service. I'm on my way to give salve a try but 
I'm having some problems there too (waiting for a response from the 
Discussion group), what suggestions can you make?


Thanks in advance,
Edgar Merino




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Salve and Guice

2008-10-21 Thread Edgar Merino
   I've been searching for information on how to use guice to lookup 
dependencies with salve, the wiki only mentions how to add the guice 
locator but I believe that is not working (at least not by it self). 
I've got a class in a wicket application that is not a component, but I 
need a service injected, so I'm using salve for this, instead of using 
@Inject to inject the service I use @Dependency, but I'm getting 
nullpointerexceptions, any hint?


Thank you,
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Salve and Guice

2008-10-21 Thread Edgar Merino
   As far as I know, salve will only modify bytecode, it should do that 
only once, after the JIT compiler comes in there should be no more 
overhead. Correct me if I'm wrong, regards.


Edgar Merino

Guðmundur Bjarni escribió:

I agree that static injection is fugly, it makes unit tests very sad and
kills puppies, but in some cases its a necessary evil. Lets say for example
that it is only needed in a very few cases, then IMO pulling in Salve is a
bit of an overkill. I've tried out Salve, liked it but it's a bit of a
commitment to use compile time weaving/instrumentation.  


Last I checked, the InjectorHolder only worked with Spring and not with
Guice. I looked into fixing that some time ago but didn't finish that work.
I've got more time now if someone is interested? :)

regards,
Guðmundur Bjarni


igor.vaynberg wrote:
  

there are cases where this approach plain old sucks.

as you mentioned, if its not a component you have to use static injection
which is fugly

class mydataprovider implements idataprovider {
  public mydataprovider() {
 InjectorHolder.getInjector().inject(this);
  }
}

another problem is that the injector creates a proxy which in certain
situations cant be done. eg your dependency is a class from a 3rd party
library that does not have a default constructor, thus cglib cannot create
a
proxy.

another advantage of salve is that it _removes_ the field from the class.
so
your classes are smaller and there are no serialization problems
whatsoever
as far as dependencies go.

-igor




  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Salve and Guice

2008-10-21 Thread Edgar Merino
Also, InjectorHolder.getInjector().inject(this) does not work with 
guice, it returns an illegalstateexception saying there's no injector 
assigned for the holder. It would be nice to have more documentation on 
how to use salve, regards.


Edgar Merino



Guðmundur Bjarni escribió:

I agree that static injection is fugly, it makes unit tests very sad and
kills puppies, but in some cases its a necessary evil. Lets say for example
that it is only needed in a very few cases, then IMO pulling in Salve is a
bit of an overkill. I've tried out Salve, liked it but it's a bit of a
commitment to use compile time weaving/instrumentation.  


Last I checked, the InjectorHolder only worked with Spring and not with
Guice. I looked into fixing that some time ago but didn't finish that work.
I've got more time now if someone is interested? :)

regards,
Guðmundur Bjarni


igor.vaynberg wrote:
  

there are cases where this approach plain old sucks.

as you mentioned, if its not a component you have to use static injection
which is fugly

class mydataprovider implements idataprovider {
  public mydataprovider() {
 InjectorHolder.getInjector().inject(this);
  }
}

another problem is that the injector creates a proxy which in certain
situations cant be done. eg your dependency is a class from a 3rd party
library that does not have a default constructor, thus cglib cannot create
a
proxy.

another advantage of salve is that it _removes_ the field from the class.
so
your classes are smaller and there are no serialization problems
whatsoever
as far as dependencies go.

-igor




  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Domain Model as interfaces

2008-10-16 Thread Edgar Merino

hello daniel,

   well yeah, maybe that can work, but still I'll have to override 
every method in the base class in order to add annotations:


...
@Id
@GeneratedStrategy(..)
public Integer getId() {
   return super.getId();
}
...

   same thing for every getter/setter methods of the entity. I would 
like to be able to switch easily between persistence providers because 
right now I'm using hibernate but would like to change the provider to 
db4o when I've got the time to do so, also this is a project I intend to 
release so anyone can add the persistence provider they need easily.


Regards,
Edgar Merino

Daniel Frisk escribió:

Hi,

I'm not sure I understand exactly what is your problem but wouldn't 
something like this:


Db4oImpl / JpaImpl / WhateverImpl ---extends--- 
AbstractBaseClassWithYourBusinessLogic ---implements--- YourInterface


Where needed you would delegate to the base class (just adding the 
impl specific annotation). Just out of interest: do you really need to 
be able to easily switch between different persistence providers?


// Daniel
jalbum.net


On 2008-10-16, at 03:00, Edgar Merino wrote:


Hello,

  I couldn't find any other place to post this, so I'm doing it here, 
(it's related to java web development anyway). I've been working on a 
project where wicket has access to the domain layer through 
interfaces because I didn't want my project to depend on any dbms, 
however I've been thinking and the main problem here lies with db4o, 
since it cannot make use of JPA annotations on entities (domain 
models). I would like to get rid of those interfaces and use concrete 
implementations to handle business code inside the entities, but then 
the above problem arises. So what recommendations can you give to 
have a fully implemented domain model (using jpa annotations) but 
still be able to use any dbms (or orm/dmbs) without having to map 
those the domain model at the service layer? I hope I can get some 
feedback on this, as it has been the main problem I've been facing 
when coding scalable web applications.


Regards,
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



More guice serialization problems

2008-10-16 Thread Edgar Merino

Hello once again,

   wicket-guice integration has been working good for me, but I needed 
to get some injected services in classes that were not Components, so I did:


Injector injector = ( (GuiceInjectorHolder) 
RequestCycle.get().getApplication().getMetaData(GuiceInjectorHolder.INJECTOR_KEY)).getInjector();

injector.injectMembers(this);

   This arises serialization problems with the Guice injector, although 
I'm not keeping a reference to the injector... this should be because 
the actual injected service is not handled by a wicket ioc proxy. Igor 
suggested salve, I've been doing some reading about it but haven't try 
it yet, but wouldn't it just throw the same exception when using salve 
since it's not a proxy either? or maybe this won't happen because salve 
would inject a local dependency (inside a method) when needed? can 
anyone clarify this for me (and maybe many others with the same doubt)?


Thanks again for the help,
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



GuiceInjectorHolder inside WebApplication

2008-10-15 Thread Edgar Merino

Hello,

   I need to hold a reference to a Guice injector inside my 
WebApplication, however since the injector is not serializable I tried 
using a GuiceInjectorHolder and keeping a reference to it in my 
WebApplication, but I'm still getting serialization exceptions when 
redeploying my application. Why didn't it work? what should I do in this 
case to keep a reference to my Guice injector? Thanks in advance.


Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: GuiceInjectorHolder inside WebApplication

2008-10-15 Thread Edgar Merino
Let me correct that last response: the problem is not solved yet. I 
thought it was but after redeploying my application again I got a 
serialization exception, why didn't the previously supplied solution 
didn't work? can anyone give me a hand on this? thanks in advance.


Edgar Merino




Edgar Merino escribió:
Ok I re-read the javadoc for the GuiceInjectorHolder and found out I 
had to use it as a MetaDataKey, so I did that in my application:


public void init() {
   //initialization code
   Injector injector = Guice.createInjector();
   setMetaData(GuiceInjectorHolder.INJECTOR_KEY, new 
GuiceInjectorHolder(injector));

}

public void someMethod() {
   Injector injector = ((GuiceInjectorHolder) 
getMetaData(GuiceInjectorHolder.INJECTOR_KEY)).getInjector();

   injector.getInstance(SomeClass.class);
}

I was thinking about adding a GuiceComponentInjector to my 
application, but I'm not using guice with wicket so I don't think I 
need that, any suggestion?


Edgar Merino



Edgar Merino escribió:

Hello,

   I need to hold a reference to a Guice injector inside my 
WebApplication, however since the injector is not serializable I 
tried using a GuiceInjectorHolder and keeping a reference to it in my 
WebApplication, but I'm still getting serialization exceptions when 
redeploying my application. Why didn't it work? what should I do in 
this case to keep a reference to my Guice injector? Thanks in advance.


Edgar Merino







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: GuiceInjectorHolder inside WebApplication

2008-10-15 Thread Edgar Merino
Ok I re-read the javadoc for the GuiceInjectorHolder and found out I had 
to use it as a MetaDataKey, so I did that in my application:


public void init() {
   //initialization code
   Injector injector = Guice.createInjector();
   setMetaData(GuiceInjectorHolder.INJECTOR_KEY, new 
GuiceInjectorHolder(injector));

}

public void someMethod() {
   Injector injector = ((GuiceInjectorHolder) 
getMetaData(GuiceInjectorHolder.INJECTOR_KEY)).getInjector();

   injector.getInstance(SomeClass.class);
}

I was thinking about adding a GuiceComponentInjector to my application, 
but I'm not using guice with wicket so I don't think I need that, any 
suggestion?


Edgar Merino



Edgar Merino escribió:

Hello,

   I need to hold a reference to a Guice injector inside my 
WebApplication, however since the injector is not serializable I tried 
using a GuiceInjectorHolder and keeping a reference to it in my 
WebApplication, but I'm still getting serialization exceptions when 
redeploying my application. Why didn't it work? what should I do in 
this case to keep a reference to my Guice injector? Thanks in advance.


Edgar Merino




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: GuiceInjectorHolder inside WebApplication

2008-10-15 Thread Edgar Merino
But I only need to keep a reference to a Guice injector in my 
WebApplication to use it across some methods in it, I don't need it 
inside my wicket components... I think the wicket-guice integration 
serves a different purpose, correct me if I'm wrong.


Edgar Merino


richardwilko escribió:

Have you looked at the wicket guice integration?  I think that does it
already.

Richard



Edgar Merino wrote:
  
Let me correct that last response: the problem is not solved yet. I 
thought it was but after redeploying my application again I got a 
serialization exception, why didn't the previously supplied solution 
didn't work? can anyone give me a hand on this? thanks in advance.


Edgar Merino




Edgar Merino escribió:

Ok I re-read the javadoc for the GuiceInjectorHolder and found out I 
had to use it as a MetaDataKey, so I did that in my application:


public void init() {
   //initialization code
   Injector injector = Guice.createInjector();
   setMetaData(GuiceInjectorHolder.INJECTOR_KEY, new 
GuiceInjectorHolder(injector));

}

public void someMethod() {
   Injector injector = ((GuiceInjectorHolder) 
getMetaData(GuiceInjectorHolder.INJECTOR_KEY)).getInjector();

   injector.getInstance(SomeClass.class);
}

I was thinking about adding a GuiceComponentInjector to my 
application, but I'm not using guice with wicket so I don't think I 
need that, any suggestion?


Edgar Merino



Edgar Merino escribió:
  

Hello,

   I need to hold a reference to a Guice injector inside my 
WebApplication, however since the injector is not serializable I 
tried using a GuiceInjectorHolder and keeping a reference to it in my 
WebApplication, but I'm still getting serialization exceptions when 
redeploying my application. Why didn't it work? what should I do in 
this case to keep a reference to my Guice injector? Thanks in advance.


Edgar Merino


  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-
http://www.richard-wilkinson.co.uk My blog:
http://www.richard-wilkinson.co.uk 
  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: GuiceInjectorHolder inside WebApplication

2008-10-15 Thread Edgar Merino
This is happening when using a WebPage, but I'm not using an injector 
there... I have a class that receives a service as a parameter, that 
service is being fetch by the guice injector and passed to the component 
in the WebApplication:


public class MyApp extends WebApplication {
   private Injector injector;
   ...

   public ListWidget getWidgets() {
  ListWidget widgets = new ArrayListWidget();
 
  //the service needs some resources injected, so is handled by the 
injector

  Service service = injector.getInstance(Service.class);
  widgets.add(new Widget(service));

  ...

  return widgets;
   }
}

class Widget {
   private Service service;

   Widget(Service service) {
  this.service = service;
   }

   public Panel getPanel() {
  return SomePanel(service);
   }
}

The above is similar to what I'm doing in my real application, below is 
the stack trace. Any help is greatly appreciated.

Edgar Merino

org.apache.wicket.WicketRuntimeException: Failed to serialize [Page 
class = org.devpower.wicket.cms.core.page.AdminPage, id = 0, version = 0]
   at 
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap.writeObject(SecondLevelCacheSessionStore.java:392)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:597)
   at 
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
   at 
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
   at 
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
   at 
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
   at 
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
   at 
org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1939)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:597)
   at 
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
   at 
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
   at 
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
   at 
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
   at 
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
   at 
org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:624)
   at 
org.apache.catalina.session.StandardManager.unload(StandardManager.java:538)
   at 
org.apache.catalina.session.StandardManager.stop(StandardManager.java:794)
   at 
org.apache.catalina.core.StandardContext.stop(StandardContext.java:5325)

   at com.sun.enterprise.web.WebModule.stop(WebModule.java:357)
   at 
org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1102)
   at 
com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2207)
   at 
com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2137)
   at 
com.sun.enterprise.server.WebModuleDeployEventListener.moduleUndeployed(WebModuleDeployEventListener.java:226)
   at 
com.sun.enterprise.server.WebModuleDeployEventListener.moduleUndeployed(WebModuleDeployEventListener.java:313)
   at 
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:976)
   at 
com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:961)
   at 
com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:464)
   at 
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:176)
   at 
com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308)
   at 
com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:226)
   at 
com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStopEvent(ServerDeploymentTarget.java:332)
   at 
com.sun.enterprise.deployment.phasing.ApplicationStopPhase.runPhase(ApplicationStopPhase.java:136)
   at 
com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
   at 
com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919)
   at 
com.sun.enterprise.deployment.phasing.PEDeploymentService.stop(PEDeploymentService.java:652

Re: GuiceInjectorHolder inside WebApplication

2008-10-15 Thread Edgar Merino
Ok, using wicket-guice now, problem solved... I didn't want to depend on 
guice inside my wicket components, but integration is perfect, so I 
guess I'll just leave it like that, thank you Igor.


Edgar Merino



Igor Vaynberg escribió:

right. you are not keeping a reference to the injector itself, but you are
giving webpage a reference to a service that is not serializable...thus your
problem.

i suggest using wicket-guice, it has provisions to make serialization work
seamlessly when you pass instances of guice services into components/pages,
even if they are not serializable.

you can read the spring page on our wiki which explains serialization
issues. wicket-guice uses an identical way of fixing this as the spring
integration.

-igor

On Wed, Oct 15, 2008 at 3:02 PM, Edgar Merino [EMAIL PROTECTED] wrote:

  

This is happening when using a WebPage, but I'm not using an injector
there... I have a class that receives a service as a parameter, that service
is being fetch by the guice injector and passed to the component in the
WebApplication:

public class MyApp extends WebApplication {
  private Injector injector;
  ...

  public ListWidget getWidgets() {
 ListWidget widgets = new ArrayListWidget();
 //the service needs some resources injected, so is handled by the
injector
 Service service = injector.getInstance(Service.class);
 widgets.add(new Widget(service));

 ...

 return widgets;
  }
}

class Widget {
  private Service service;

  Widget(Service service) {
 this.service = service;
  }

  public Panel getPanel() {
 return SomePanel(service);
  }
}

The above is similar to what I'm doing in my real application, below is the
stack trace. Any help is greatly appreciated.
Edgar Merino

org.apache.wicket.WicketRuntimeException: Failed to serialize [Page class =
org.devpower.wicket.cms.core.page.AdminPage, id = 0, version = 0]
  at
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap.writeObject(SecondLevelCacheSessionStore.java:392)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
  at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
  at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
  at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
  at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
  at
org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1939)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
  at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
  at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
  at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
  at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
  at
org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:624)
  at
org.apache.catalina.session.StandardManager.unload(StandardManager.java:538)
  at
org.apache.catalina.session.StandardManager.stop(StandardManager.java:794)
  at
org.apache.catalina.core.StandardContext.stop(StandardContext.java:5325)
  at com.sun.enterprise.web.WebModule.stop(WebModule.java:357)
  at
org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1102)
  at
com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2207)
  at
com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2137)
  at
com.sun.enterprise.server.WebModuleDeployEventListener.moduleUndeployed(WebModuleDeployEventListener.java:226)
  at
com.sun.enterprise.server.WebModuleDeployEventListener.moduleUndeployed(WebModuleDeployEventListener.java:313)
  at
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:976)
  at
com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:961)
  at
com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:464)
  at
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:176

Guice: injection outside Component

2008-10-15 Thread Edgar Merino

Hello again,

   using guice's @Inject inside any component works perfect, however 
I've got some objects (not components) that reside inside a component 
and need an injected service, since wicket-guice handles only injection 
inside components, I'm getting null services:


public class Instantiator {
   @Inject Service service;

   public Panel getPanel(String id) {
  Author author = service.findAuthor(me);
  return new SomePanel(id, author);
   }
}


I need to fetch the Author outside the panel, the panel is not able to 
fetch it. One approach might be to get the service from the Application, 
but I do not want to do this since I don't want the application to know 
about my Instantiator class, is there a better approach to accomplish 
what I need? thanks in advance.


Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Guice: injection outside Component

2008-10-15 Thread Edgar Merino

Thank you Jeremy, I've tried that but it did not work:

public class Instantiator {
   public Instantiator() {
  Injector injector = ( (GuiceInjectorHolder) CmsApplication.get()
   
.getMetaData(GuiceInjectorHolder.INJECTOR_KEY)).getInjector();


  injector.injectMembers(this);
   }

   ...
}

maybe I'm doing something wrong? any other solution? thank you

Edgar Merino




Jeremy Thomerson escribió:

Try adding a constructor and putting this line in it:

*InjectorHolder*.*getInjector*().*inject*(*this*);

Works with Spring - haven't used Guice personally.

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Guice: injection outside Component

2008-10-15 Thread Edgar Merino
Let me correct that last post, I forgot to add the @Inject annotation to 
the service... it's working... thank you!


Edgar Merino





Edgar Merino escribió:

Thank you Jeremy, I've tried that but it did not work:

public class Instantiator {
   public Instantiator() {
  Injector injector = ( (GuiceInjectorHolder) CmsApplication.get()
   
.getMetaData(GuiceInjectorHolder.INJECTOR_KEY)).getInjector();


  injector.injectMembers(this);
   }

   ...
}

maybe I'm doing something wrong? any other solution? thank you

Edgar Merino




Jeremy Thomerson escribió:

Try adding a constructor and putting this line in it:

*InjectorHolder*.*getInjector*().*inject*(*this*);

Works with Spring - haven't used Guice personally.

  






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Domain Model as interfaces

2008-10-15 Thread Edgar Merino

Hello,

   I couldn't find any other place to post this, so I'm doing it here, 
(it's related to java web development anyway). I've been working on a 
project where wicket has access to the domain layer through interfaces 
because I didn't want my project to depend on any dbms, however I've 
been thinking and the main problem here lies with db4o, since it cannot 
make use of JPA annotations on entities (domain models). I would like to 
get rid of those interfaces and use concrete implementations to handle 
business code inside the entities, but then the above problem arises. So 
what recommendations can you give to have a fully implemented domain 
model (using jpa annotations) but still be able to use any dbms (or 
orm/dmbs) without having to map those the domain model at the service 
layer? I hope I can get some feedback on this, as it has been the main 
problem I've been facing when coding scalable web applications.


Regards,
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Submit a form automatically after N seconds

2008-10-07 Thread Edgar Merino
Hello, I've been trying to add this functionality to a component, after 
(say) 120 seconds I want to submit the form automatically (via ajax) in 
order to create a backup of the information hold at that time by the 
component. I've been looking at ajaxformsubmitbehavior but I don't see 
how to make this work with what I need. I think an 
abstractajaxtimerbehavior is what I need here but I need to know how to 
submit the form in the onTimer method.


Thanks in advance.
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reusable DateColumn component

2008-10-05 Thread Edgar Merino
Hello, a few days ago someone requested some advice on how to format the 
date within an IColumn, I suggested DateColumn that depended on his 
code, but I've been having this necessity in several ocassions too, so 
I've come up with a true reusable DateColumn component that inherits 
from PropertyColumn, so using it is as simple as:


(DateColumn class shown below)

ListIColumn cols = new ArrayListIColumn();
cols.add(new DateColumn(new Model(header title), propertyExpression));

No extra code needed, regards.
Edgar Merino


import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.lang.PropertyResolver;
import 
org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;


/**
* PropertyColumn descendent, used to apply a format to a Date field to 
be displayed

* by a Label in a DataTable
*
* @author Edgar Merino
*/
public class DateColumn extends PropertyColumn {   
   public  static final String DEFAULT_DATE_PATTERN = dd MMM  '@' 
hh:mm a;
   private String datePattern;   
  
   public DateColumn(IModel displayModel, String propertyExpression) {

   this(displayModel, DEFAULT_DATE_PATTERN, propertyExpression);
   }   
  
   public DateColumn(IModel displayModel, String datePattern, String 
propertyExpression) {

   this(displayModel, null, datePattern, propertyExpression);
   }
  
   public DateColumn(IModel displayModel, String sortProperty, String 
datePattern, String propertyExpression) {
   super(displayModel, propertyExpression);   
   this.datePattern = datePattern;

   }

   @Override
   protected IModel createLabelModel(IModel itemModel) {
   Date date = (Date) 
PropertyResolver.getValue(getPropertyExpression(), itemModel.getObject());
   SimpleDateFormat df = (SimpleDateFormat) 
DateFormat.getDateInstance();

   df.applyPattern(datePattern);
  
   return new Model(df.format(date));

   }
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wrapped FeedbackPanel and AjaxRequestTarget

2008-10-05 Thread Edgar Merino
Never mind, I guess this can be solved by calling the actual Parent that 
holds the FeedbackPanel:


Component parent = null;
do {
   parent = feedbackPanel.getParent();
} while(parent.getParent() != null);

Regards,
Edgar Merino


Edgar Merino escribió:

Hello once again,

   I've been coding some Panels that might (or might not) use a 
FeedbackPanel to inform about their states, these panels are Ajax 
enabled. Since the feedbackPanel does not reside on the panel itself 
(it is added to the panels parent component), I've decided to come out 
with a wrapper panel that should support this out of the box (shown 
below), the problem is that after calling infoFeedback(some msg, 
target) I don't see the message displayed in the Parent component (a 
WebPage). I thought calling FeedbackPanel#getParent()#info(String msg) 
will do the trick, but I guess I was wrong. I would really appreciate 
any help.


public abstract class FeedbackHolderPanel extends Panel {
   private FeedbackPanel feedbackPanel;
 public FeedbackHolderPanel(String id) {
   super(id);
   }
 public Panel addFeedbackPanel(FeedbackPanel feedbackPanel) 
{  this.feedbackPanel = feedbackPanel;

   feedbackPanel.setOutputMarkupId(true);
 return this;
   }
 protected void infoFeedback(String msg, AjaxRequestTarget target) {
   if (feedbackPanel != null) {
   feedbackPanel.getParent().info(msg);
   addToTarget(target);  }
   }
 .. {same goes for warn and error} ...
 protected FeedbackPanel getFeedbackPanel() {
   return feedbackPanel;
   }
 private void addToTarget(AjaxRequestTarget target) {
   if (target != null) {
   target.addComponent(feedbackPanel);
   }
   }
}

Thanks in advance
Edgar Merino




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Wrapped FeedbackPanel and AjaxRequestTarget

2008-10-04 Thread Edgar Merino

Hello once again,

   I've been coding some Panels that might (or might not) use a 
FeedbackPanel to inform about their states, these panels are Ajax 
enabled. Since the feedbackPanel does not reside on the panel itself (it 
is added to the panels parent component), I've decided to come out with 
a wrapper panel that should support this out of the box (shown below), 
the problem is that after calling infoFeedback(some msg, target) I 
don't see the message displayed in the Parent component (a WebPage). I 
thought calling FeedbackPanel#getParent()#info(String msg) will do the 
trick, but I guess I was wrong. I would really appreciate any help.


public abstract class FeedbackHolderPanel extends Panel {
   private FeedbackPanel feedbackPanel;
  
   public FeedbackHolderPanel(String id) {

   super(id);
   }
  
   public Panel addFeedbackPanel(FeedbackPanel feedbackPanel) {   
   this.feedbackPanel = feedbackPanel;

   feedbackPanel.setOutputMarkupId(true);
  
   return this;

   }
  
   protected void infoFeedback(String msg, AjaxRequestTarget target) {

   if (feedbackPanel != null) {
   feedbackPanel.getParent().info(msg);
   addToTarget(target);   
   }

   }
  
   .. {same goes for warn and error} ...
  
   protected FeedbackPanel getFeedbackPanel() {

   return feedbackPanel;
   }
  
   private void addToTarget(AjaxRequestTarget target) {

   if (target != null) {
   target.addComponent(feedbackPanel);
   }
   }
}

Thanks in advance
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Contribute to the body tag (onload)

2008-10-03 Thread Edgar Merino

Hello,

   Is it possible to contribute to the body html tag from within 
children pages? directly in markup, like when using the wicket:head 
tag (without modifying the java WebPage).


Thanks in advance.
Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DefaultDataTable with date column

2008-10-02 Thread Edgar Merino
Or simply use an AbstractColumn for that, you can even create a reusable 
DateColumn:


public class DateColumn extends AbstractColumn {
   private String datePattern; //you can have a Pattern instead

   //You can overload the constructor, to have default date patterns 
for example

   public DateColumn(IModel columnName, String datePattern) {
  super(columnName);
  this.datePattern = datePattern;
   }

   public void populateItem(Item cellItem, String componentId, IModel 
model) {

  Document doc = (Document) model.getModelObject();
 
  SimpleDateFormat df = (SimpleDateFormat) DateFormat.getInstance();

  df.applyPattern(datePattern);
  cellItem.add(new Label(componentId, 
df.format(doc.getDeliveryDate(;

   }
}

Then just use this class as you would with any other column, along with 
a pattern to apply to the format:


ListIColumn columns = new ArrayListIColumn();
columns.add(new DateColumn(new Model(Delivery date), dd MMM  '@' 
hh:mm a));



Regards,
Edgar Merino




Jeremy Thomerson escribió:

The default java.util.Date converter within Wicket has varied between
releases.  I suggest adding this to the init method of your application
class and controlling the date format yourself if you need a specific
format:

((ConverterLocator) getConverterLocator()).set(Date.class, new
IConverterDate() {
private static final long serialVersionUID = 1L;
private final DateFormat mFormat = new
SimpleDateFormat(MM/dd/yy hh:mm:ss.SSS);
public Date convertToObject(String value, Locale locale) {
try {
return mFormat.parse(value);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}

public String convertToString(Date value, Locale locale) {
return mFormat.format(value);
}

});

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RepeatingView: add new component at specified index

2008-10-01 Thread Edgar Merino

Anyone?


Edgar Merino escribió:

Hello again,

   I'm using version 1.3.4 (will wait until the generics version reach 
its final state), the functionality I need with the RepeatingView is 
because I want a BasePage to contain a right panel (represented by a 
RepeatingView), where other panels can be added to it. But this may be 
done extending that BasePage and then adding the needed panels at the 
specified index given. I've seen the MarkupContainer implementation, 
and it holds its sequence of elements in an Object (children), but 
access to it is private (because of various operations that need to be 
performed before casting it to a List, array or leaving it as an object).


   I think this can be accomplished by adding all the needed panels to 
a List and call a method at the end of the BasePage's children so all 
those panels get added to the RepeatingView in the specified order. Is 
there some way to make this automatic from the BasePage, so I can 
avoid having all the children of BasePage call that specific method at 
the end of its constructor? (perhaps, using a callback? will 
onBeforeRender() work?).


Edgar Merino



Igor Vaynberg escribió:

in 1.4 there is markupcontainer.swap()

-igor

On Tue, Sep 30, 2008 at 3:40 AM, Edgar Merino [EMAIL PROTECTED] 
wrote:
 

Hello,

  is there any way to control the underlaying Collection a
WebMarkupContainer holds? So I can control where to insert the new
components to be added (with an index, for example). Thanks in advance.

Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RepeatingView: add new component at specified index

2008-10-01 Thread Edgar Merino

Thank you!

Edgar Merino


Igor Vaynberg escribió:

you can override renderiterator() and return one that iterates
chlildren in any order you wish

-igor

On Tue, Sep 30, 2008 at 4:34 PM, Edgar Merino [EMAIL PROTECTED] wrote:
  

Hello again,

  I'm using version 1.3.4 (will wait until the generics version reach its
final state), the functionality I need with the RepeatingView is because I
want a BasePage to contain a right panel (represented by a RepeatingView),
where other panels can be added to it. But this may be done extending that
BasePage and then adding the needed panels at the specified index given.
I've seen the MarkupContainer implementation, and it holds its sequence of
elements in an Object (children), but access to it is private (because of
various operations that need to be performed before casting it to a List,
array or leaving it as an object).

  I think this can be accomplished by adding all the needed panels to a List
and call a method at the end of the BasePage's children so all those panels
get added to the RepeatingView in the specified order. Is there some way to
make this automatic from the BasePage, so I can avoid having all the
children of BasePage call that specific method at the end of its
constructor? (perhaps, using a callback? will onBeforeRender() work?).

Edgar Merino



Igor Vaynberg escribió:


in 1.4 there is markupcontainer.swap()

-igor

On Tue, Sep 30, 2008 at 3:40 AM, Edgar Merino [EMAIL PROTECTED] wrote:

  

Hello,

 is there any way to control the underlaying Collection a
WebMarkupContainer holds? So I can control where to insert the new
components to be added (with an index, for example). Thanks in advance.

Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DefaultDataTable with date column

2008-10-01 Thread Edgar Merino
Use java.text.DateFormat for that matter (take a look at 
SimpleDateFormat in case you need more control over how you want your 
date to be formatted).


Edgar Merino


Pablo S. escribió:
Hi, I would like to know how I can format a value from 1 column that 
is a date. I've a sortable dataprovider that contains my object, and 
one of the fields is a date. The html table shows the digits of the 
hour of the date (example: 00:00) instead of  something like this 
2000/02/03


Thanks
Pablo



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RepeatingView: add new component at specified index

2008-09-30 Thread Edgar Merino

Hello,

   is there any way to control the underlaying Collection a 
WebMarkupContainer holds? So I can control where to insert the new 
components to be added (with an index, for example). Thanks in advance.


Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RepeatingView: add new component at specified index

2008-09-30 Thread Edgar Merino

Hello again,

   I'm using version 1.3.4 (will wait until the generics version reach 
its final state), the functionality I need with the RepeatingView is 
because I want a BasePage to contain a right panel (represented by a 
RepeatingView), where other panels can be added to it. But this may be 
done extending that BasePage and then adding the needed panels at the 
specified index given. I've seen the MarkupContainer implementation, and 
it holds its sequence of elements in an Object (children), but access to 
it is private (because of various operations that need to be performed 
before casting it to a List, array or leaving it as an object).


   I think this can be accomplished by adding all the needed panels to 
a List and call a method at the end of the BasePage's children so all 
those panels get added to the RepeatingView in the specified order. Is 
there some way to make this automatic from the BasePage, so I can avoid 
having all the children of BasePage call that specific method at the end 
of its constructor? (perhaps, using a callback? will onBeforeRender() 
work?).


Edgar Merino



Igor Vaynberg escribió:

in 1.4 there is markupcontainer.swap()

-igor

On Tue, Sep 30, 2008 at 3:40 AM, Edgar Merino [EMAIL PROTECTED] wrote:
  

Hello,

  is there any way to control the underlaying Collection a
WebMarkupContainer holds? So I can control where to insert the new
components to be added (with an index, for example). Thanks in advance.

Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Add more than one component to an Item (repeaters)

2008-09-25 Thread Edgar Merino

Hello,

   I've got a DataTable that needs to add to each of its Items a Link 
and a Label, since I've only get one componentId from the 
populateItem(Item cellItem, String componentId, IModel model) method, I 
don't know what to do to be able to accomplish what I need.


   This is what I need:

public void populateItem(Item cellItem, String componentId, IModel model) {
   Link link = new Link(componentId) {
  public void onClick() {
 //do Something
  }
   }
   link.add(new Label(WHAT SHOULD I PUT HERE), label);

   cellItem.add(link);
}

   I hope someone can give me a hint on what to do, thank you in advance.

Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Add more than one component to an Item (repeaters)

2008-09-25 Thread Edgar Merino

Thank you both for the advice, already working, thank you.


Nino Saturnino Martinez Vazquez Wael escribió:

I did it once this way:


AjaxLinkPanel.java

public abstract class AjaxLinkPanel extends Panel {
   public AjaxLinkPanel(String id, String title) {
   super(id);
   AjaxLink link = new AjaxLink(ajaxLink) {
   @Override
   public void onClick(AjaxRequestTarget target) {
   onClicked(target);
   }
   };
   link.add(new Label(title,title));
   add(link);

   }

   protected abstract void onClicked(AjaxRequestTarget target);

}

AjaxLinkPanel.html
wicket:panel
 a href=# wicket:id=ajaxLink class=buttonspan 
wicket:id=title/span/a


   wicket:child /
/wicket:panel


AjaxFallbackDefaultDataTable

   columns
   .add(new AbstractColumn(new 
StringResourceModel(action, null)) {
   public void populateItem(Item cellItem, String 
componentId,

   IModel model) {

...
   }
   };
   cellItem.add(link);
   }
   });




Alexandre Lenoir wrote:
You can create your own component that involves many subcomponents 
and add

it to your datatable. Too simple?

On Thu, Sep 25, 2008 at 11:28 AM, Nino Saturnino Martinez Vazquez Wael 
[EMAIL PROTECTED] wrote:

 

Do it as a panel..?


Edgar Merino wrote:

   

Hello,

  I've got a DataTable that needs to add to each of its Items a 
Link and a

Label, since I've only get one componentId from the populateItem(Item
cellItem, String componentId, IModel model) method, I don't know 
what to do

to be able to accomplish what I need.

  This is what I need:

public void populateItem(Item cellItem, String componentId, IModel 
model)

{
  Link link = new Link(componentId) {
 public void onClick() {
//do Something
 }
  }
  link.add(new Label(WHAT SHOULD I PUT HERE), label);

  cellItem.add(link);
}

  I hope someone can give me a hint on what to do, thank you in 
advance.


Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  

--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





  





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Add caption to DataTable

2008-09-25 Thread Edgar Merino

Hello again,

   Is it possible to add a caption to a DataTable? Toolbars are not 
good for these, any advice on how to do this? Regards.


Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Add caption to DataTable

2008-09-25 Thread Edgar Merino

Never mind, solved it using some extra css.


Edgar Merino escribió:

Hello again,

   Is it possible to add a caption to a DataTable? Toolbars are not 
good for these, any advice on how to do this? Regards.


Edgar Merino




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Create permanent sessions (or the like)

2008-09-23 Thread Edgar Merino

Hello,

I've got a Panel that contains some AjaxLinks, when clicked they should 
refresh the data in a DataView, but if the Session expires, I get a 
PageExpired exception, is there any way to avoid this without adding a 
TimerBehavior to poll the server every N minutes? (an example of this 
can be seeing by going to the wicket examples page in the linkomatic 
application, after the session expires you can no longer click the ajax 
link counter without receiving a PageExpired exception).


Thanks in advance.

Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Create permanent sessions (or the like)

2008-09-23 Thread Edgar Merino
Would do, I think there are not many security implications in doing 
this, am I correct?


Thank you,
Edgar Merino

Piller Sébastien escribió:

How about increasing the session's timeout?

Set it to 10 hours, then nobody will get a PageExpired in a normal use

Edgar Merino a écrit :

Hello,

I've got a Panel that contains some AjaxLinks, when clicked they 
should refresh the data in a DataView, but if the Session expires, I 
get a PageExpired exception, is there any way to avoid this without 
adding a TimerBehavior to poll the server every N minutes? (an 
example of this can be seeing by going to the wicket examples page in 
the linkomatic application, after the session expires you can no 
longer click the ajax link counter without receiving a PageExpired 
exception).


Thanks in advance.

Edgar Merino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Create permanent sessions (or the like)

2008-09-23 Thread Edgar Merino

Thank you again, no sensitive information is to be used.

Edgar Merino



Piller Sébastien escribió:

afaik, there isn't much...

if your manage normal data, no problem. But with financial, banking, 
etc. when you have to manage cash, or sensible data, I'd discourage 
you to do so... if a user forget to logout or to close his browser and 
go out, then anybody can continue his session.


There is probably some others potential issues, but you'll have to ask 
other ;)


Edgar Merino a écrit :
Would do, I think there are not many security implications in doing 
this, am I correct?


Thank you,
Edgar Merino



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]