Re: Bookmarkable images from db

2009-12-08 Thread Peter Dotchev

Hi,

Actually there is a clean and easy Wicket way to do this.
No servlets, no URL hand writing.
It is achieved by using a shared resource with parameters as mentioned
above.
I have described it 
http://dotev.blogspot.com/2009/11/serving-images-and-other-resources-with.html
here .

Best regards,
Peter


Juan Pablo Picasso wrote:
> 
> Hi, I've implemented this by mounting a bookmarkable page and writing into
> the response. I've imagine this bypasses some useful wicket features, but
> was the only way I use bookmarkable urls like "/image/someImageName" for
> mapping user uploaded images:
> 
> #Application
> this.mount(new IndexedParamUrlCodingStrategy("/image", ImagePage.class));
> 
> #ImagePage class
> public class ImagePage extends WebPage {
> 
> private static Logger logger =
> LoggerFactory.getLogger(ImagePage.class);
> 
> @Override
> protected void onRender(MarkupStream markupStream) {
> String imageName = (String)
> this.getRequest().getParameterMap().get("0");
> 
> byte[] fileContents = PersistenceFacade.readFile(imageName);
> try {
> this.getResponse().getOutputStream().write(fileContents);
> } catch (IOException e) {
> logger.error("Could not write image [" + imageName + "]
> into
> the response", e);
> }
> }
> }
> }
> 
> Any suggestions are welcome,
> regards!
> Juan
> 
> On Mon, Nov 2, 2009 at 3:00 PM, Alex Objelean
> wrote:
> 
>>
>> Exactly. You can see the example posted by Vytautas Racelis earlier at
>> this
>> link:
>>
>> http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-repository/src/main/java/org/xaloon/wicket/component/resource/ImageLink.java
>>
>> I prefer to do it this way:
>> http://pastebin.com/m328e21ff
>>
>> The first example allow you to use directly an Image component, while the
>> second allows you to build the url of any resource by name..
>>
>> Alex Objelean
>>
>>
>> Peter Dotchev wrote:
>> >
>> > Hi Alex,
>> >
>> > I check SharedResources, but as I understand it I would have to add
>> there
>> > a Resource object for each image.
>> >
>> > After checking again the javadoc there might be another way.
>> > Display each image with Image constructor that takes ValueMap and
>> provide
>> > there some image identification.
>> > Add a single Resource object for all images and from
>> getResourceStream()
>> > implementation to call getParameters() which will return the same
>> > parameters passed to Image constructor and tell me which image to
>> return.
>> > Will this work?
>> >
>> > Best regards,
>> > Petar
>> >
>> >
>> > Alexandru Objelean wrote:
>> >>
>> >> Besides the servlet, there is also a wicket way of do it:
>> >>
>> >> - Use shared resource, which is stateless and bookmarkable
>> >>
>> >> If you need more informations about this approach, search on forum or
>> >> just ask... and I'll provide you with some examples of how I do it..
>> >>
>> >> Alex Objelean
>> >>
>> >>
>> >> Peter Dotchev wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> My app allows users to upload images and I store them in JCR
>> >>> <http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
>> >>> get InputStream for each one of them.
>> >>> I want to display images in specific pages and I want image URLs to
>> be
>> >>> stable/bookmarkable. Also I don't want these pages to use the session
>> in
>> >>> any way.
>> >>> I checked again chapter 9 about images from Wicket In Action but such
>> >>> use case is not addressed there.
>> >>>
>> >>> I found that SharedResources allows for stable URLs, but I cannot
>> >>> register each individual image.
>> >>>
>> >>> What approach would you suggest?
>> >>>
>> >>> Best regards,
>> >>> Peter
>> >>>
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Bookmarkable-images-from-db-tp26154577p26157757.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Bookmarkable-images-from-db-tp26154577p26693928.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: ExternalLink takes IModel for label

2009-11-23 Thread Peter Dotchev

https://issues.apache.org/jira/browse/WICKET-2588


igor.vaynberg wrote:
> 
> yep, so we cant fix it in 1.4.x, but add an rfe for 1.5
> 
> -igor
> 
> On Sun, Nov 22, 2009 at 2:24 PM, Peter Dotchev  wrote:
>> Hi Wicketeers,
>>
>> I just noticed that this constructor
>>   public ExternalLink(final String id, final IModel href, final
>> *IModel* label)
>> takes  IModel for label.
>> This is somewhat limiting since the model could hold a number or a date
>> for
>> example.
>> Actually passing a raw IModel with any object inside works just fine.
>>
>> It would be more appropriate if this constructor takes IModel for the
>> label as done in Label constructor.
>> Unfortunately ExternalLink offers a public method getLabel() that returns
>> the label as IModel.
>> So it seems changing it would break compatibility.
>>
>> Using wicket 1.4.1.
>>
>> Best regards,
>> Peter
>>
>>
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/ExternalLink-takes-IModel%3CString%3E-for-label-tp26470239p26477595.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



ExternalLink takes IModel for label

2009-11-22 Thread Peter Dotchev

Hi Wicketeers,

I just noticed that this constructor
   public ExternalLink(final String id, final IModel href, 
final *IModel* label)

takes  IModel for label.
This is somewhat limiting since the model could hold a number or a date 
for example.

Actually passing a raw IModel with any object inside works just fine.

It would be more appropriate if this constructor takes IModel for the 
label as done in Label constructor.
Unfortunately ExternalLink offers a public method getLabel() that 
returns the label as IModel.

So it seems changing it would break compatibility.

Using wicket 1.4.1.

Best regards,
Peter



Re: Why don't all Link classes support a label like ExternalLink does?

2009-11-22 Thread Peter Dotchev

Hi,

I also find myself often in the situation to create two components Link +
Label for a link.
So, I would appreciate if Link's used their model for the element content.

Best regards,
Peter


Martijn Dashorst wrote:
> 
> Not everybody puts a label inside a link. Not as common as you might
> think it is. It is also common to attach a link to a span, div, td or
> even tr.
> 
> Martijn
> 
> On Wed, Dec 17, 2008 at 12:29 AM, Phil Grimm  wrote:
>> Guys,
>>
>> Maybe I'm missing something, but it seems odd that I need to create
>> custom
>> components in order to set the label on a link. The ability to set the
>> label
>> (the text the user sees) on a link seems like a very basic use case. Why
>> would that not be provided in all Link classes?
>>
>> So far, I've needed to create my own LabeledLink, LabeledSubmitLink and
>> now
>> it looks like I need to create a LabeledPageLink in order to do what
>> ExternalLink already provides.
>>
>> I'm not sure this is the best way to do this, but this is what I've done
>> to
>> implement a Link that allows the label to be specified.
>>
>> public class LabeledLink extends Link
>> {
>>protected String label;
>>
>>public LabeledLink(java.lang.String id, IModel model, String label)
>>{
>>super(id, model);
>>this.label = label;
>>}
>>
>>@Override
>>protected void onComponentTagBody(final MarkupStream markupStream,
>> final
>> ComponentTag openTag)
>>{
>>replaceComponentTagBody(markupStream, openTag, label);
>>}
>> }
>>
>> Is there a better way?
>> Am I missing something?
>>
>> Thanks!
>> Phil
>>
> 
> 
> 
> -- 
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.4 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Why-don%27t-all-Link-classes-support-a-label-like-ExternalLink-does--tp21044160p26469569.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: WicketFilter.getLastModified creates a RequestCycle but does not clean it up

2009-11-09 Thread Peter Dotchev

created jira item
https://issues.apache.org/jira/browse/WICKET-2566

Regards,
Peter


igor.vaynberg wrote:
> 
> peter, please open a jira issue. looks like a bug to me.
> 
> -igor
> 
> On Sat, Nov 7, 2009 at 1:52 PM, Peter Dotchev  wrote:
>> Hi Wicketeers,
>>
>> I noticed that WicketFilter.getLastModified creates a RequestCycle but
>> does
>> not /detach /it, so onEndRequest is not called.
>> I use JCR and open a session to it on first use (lazy init). I store the
>> JCR
>> session in th RequestCycle. I close the JCR session in
>> RequestCycle.onEndRequest (overriden). Kind of Open Session In View
>> pattern.
>> When WicketFilter.getLastModified calls Resource.getResourceStream() I
>> have
>> to open a JCR session to stream the requested resource. But then
>> onEndRequest is not called on the RequestCycle so the JCR session remains
>> open.
>>
>> By debugging I found the following sequence in WicketFilter:
>> doFilter
>>   getLastModified
>>      webApplication.newRequestCycle
>>      resource.getResourceStream
>>      // requestCycle.detach - this is commented
>>      requestCycle.unset // this does not call onEndRequest
>>   doGet
>>      webApplication.newRequestCycle // second RequestCycle is created
>>      cycle.request() // this calls again getResourceStream but also
>> RequestCycle.detach
>>
>> It turns out two RequestCycle's are created but only the second one is
>> detached. Also Resource.getResourceStream is called twice. This is all
>> for
>> one request.
>>
>> I use Wicket 1.4.1.
>>
>> Best regards,
>> Peter
>>
>>
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/WicketFilter.getLastModified-creates-a-RequestCycle-but-does-not-clean-it-up-tp26249003p26262469.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



WicketFilter.getLastModified creates a RequestCycle but does not clean it up

2009-11-07 Thread Peter Dotchev

Hi Wicketeers,

I noticed that WicketFilter.getLastModified creates a RequestCycle but 
does not /detach /it, so onEndRequest is not called.
I use JCR and open a session to it on first use (lazy init). I store the 
JCR session in th RequestCycle. I close the JCR session in 
RequestCycle.onEndRequest (overriden). Kind of Open Session In View pattern.
When WicketFilter.getLastModified calls Resource.getResourceStream() I 
have to open a JCR session to stream the requested resource. But then 
onEndRequest is not called on the RequestCycle so the JCR session 
remains open.


By debugging I found the following sequence in WicketFilter:
doFilter
   getLastModified
  webApplication.newRequestCycle
  resource.getResourceStream
  // requestCycle.detach - this is commented
  requestCycle.unset // this does not call onEndRequest
   doGet
  webApplication.newRequestCycle // second RequestCycle is created
  cycle.request() // this calls again getResourceStream but also 
RequestCycle.detach


It turns out two RequestCycle's are created but only the second one is 
detached. Also Resource.getResourceStream is called twice. This is all 
for one request.


I use Wicket 1.4.1.

Best regards,
Peter



Re: Bookmarkable images from db

2009-11-02 Thread Peter Dotchev

Hi Alex,

I check SharedResources, but as I understand it I would have to add there a
Resource object for each image.

After checking again the javadoc there might be another way.
Display each image with Image constructor that takes ValueMap and provide
there some image identification.
Add a single Resource object for all images and from getResourceStream()
implementation to call getParameters() which will return the same parameters
passed to Image constructor and tell me which image to return.
Will this work?

Best regards,
Petar


Alexandru Objelean wrote:
> 
> Besides the servlet, there is also a wicket way of do it:
> 
> - Use shared resource, which is stateless and bookmarkable 
> 
> If you need more informations about this approach, search on forum or just
> ask... and I'll provide you with some examples of how I do it..
> 
> Alex Objelean
> 
> 
> Peter Dotchev wrote:
>> 
>> Hi,
>> 
>> My app allows users to upload images and I store them in JCR 
>> <http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can 
>> get InputStream for each one of them.
>> I want to display images in specific pages and I want image URLs to be 
>> stable/bookmarkable. Also I don't want these pages to use the session in 
>> any way.
>> I checked again chapter 9 about images from Wicket In Action but such 
>> use case is not addressed there.
>> 
>> I found that SharedResources allows for stable URLs, but I cannot 
>> register each individual image.
>> 
>> What approach would you suggest?
>> 
>> Best regards,
>> Peter
>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Bookmarkable-images-from-db-tp26154577p26157711.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Bookmarkable images from db

2009-11-01 Thread Peter Dotchev

Hi,

My app allows users to upload images and I store them in JCR 
. I can 
get InputStream for each one of them.
I want to display images in specific pages and I want image URLs to be 
stable/bookmarkable. Also I don't want these pages to use the session in 
any way.
I checked again chapter 9 about images from Wicket In Action but such 
use case is not addressed there.


I found that SharedResources allows for stable URLs, but I cannot 
register each individual image.


What approach would you suggest?

Best regards,
Peter




Data validation and form components

2009-04-28 Thread Peter Dotchev

Hi,

Setter methods of my business logic classes perform validation and throw 
exceptions if given parameter is invalid.

I don't have separate methods for data validation.
In my wicket form I use CompoundPropertyModel which sets user entered 
values directly in the business object.
If the user enters invalid value, the setter method throws some 
exception and the error page is shown.
How can I intercept this exception and show the error message in a 
feedback panel keeping the form open?


Best regards,
Peter

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



Why is LoadableDetachableModel read-only?

2007-11-02 Thread Peter Dotchev

Hi,

setObject() is not supported on LoadableDetachableModel because it extends
AbstractReadOnlyModel.
What is the reason for this?

This way LoadableDetachableModel  cannot be used with form controls.

In my case I have a DropDownChoice with a list of non-serializable objects.
What kind of model could I use to store the selected object?

Best regards,
Petar

-- 
View this message in context: 
http://www.nabble.com/Why-is-LoadableDetachableModel-read-only--tf4740811.html#a13556640
Sent from the Wicket - User mailing list archive at Nabble.com.


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



substitute same value in several places

2007-09-27 Thread Peter Dotchev

Hi,

I'd like to use the same value in several places of a page, e.g. two labels
with same content.
Let's say I want to substitute the same property using
CompoundPropertyModel.

How can I do that in Wicket 1.3?

Thanks for your help.

Peter

-- 
View this message in context: 
http://www.nabble.com/substitute-same-value-in-several-places-tf4530268.html#a12927782
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Custom page <-> class mapping

2007-08-31 Thread Peter Dotchev

Hello,

I'd like to use custom convention for page class names.
Something like Home.html <-> HomePage.class
How can I do this in wicket 1.3?
I don't want to mount each page separately.
I guess I should implement IRequestTargetUrlCodingStrategy but would not
like to do it from scratch.
Any hints?

Best regards,
Peter

-- 
View this message in context: 
http://www.nabble.com/Custom-page-%3C-%3E-class-mapping-tf4358968.html#a12422814
Sent from the Wicket - User mailing list archive at Nabble.com.


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