myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Vieujot <svieu...@apache.org>
Subject Re: New s:graphicImageAjax component.
Date Thu, 29 Sep 2005 13:16:40 GMT
I just commited some changes, (as the RESTORE_VIEW phase), but didn't
before.

Constructing a minimal component tree would be the best solution I
guess. Do you know how to do that ?

In the current code, you'll find an attempt to provide
initializationParameters, but it doesn't work right now, as the tree
isn't constructed.
So I guess combining this with a serialized
<f:view><x:graphicImageAjax/></f:view> would be the best solution.

On Thu, 2005-09-29 at 03:47 -0400, Mike Kienenberger wrote:

> Ok.  Now that I have graphicImageAjax working under facelets
> (providing the component tree is small enough), I've gone ahead and
> switched it from INVOKE_APPLICATION to RESTORE_VIEW (which was already
> in the source commented out).  It seems to work, but maybe you changed
> it because you ran into problems under some cases?
> 
> On 9/29/05, Mike Kienenberger <mkienenb@gmail.com> wrote:
> > What about the possibility of manually constructing a minimal
> > component tree and using that instead?  Perhaps just a UIViewRoot and
> > a copy of the graphicImageAjax?  The jsf state should be small enough
> > in that case.
> >
> > Also, why do you wait until after phase invokeApplication?   Isn't it
> > sufficient to render a response after the restoreView phase?
> >
> >
> > On 9/28/05, Sylvain Vieujot <svieujot@apache.org> wrote:
> > >  Yes, probably.
> > >  I tested it with Tomcat, and it works fine, but I didn't try on a big page
> > > though.
> > >  A fix to this problem could be to have an optional
> > > initializationParameters, and omit the jsf state.
> > >  It wouldn't be as transparent, but it still would remove the need to do a
> > > special purpose servlet, and it would work with much smaller URLs.
> > >  Example :
> > >
> > >  <x:graphicImageBytes
> > >      initializationParameters="#{imageUnid=09183912}"
> > >
> > > getContentTypeMethod="#{graphicImageAjaxBean.upImage.getContentType}"
> > >
> > > getBytesMethod="#{graphicImageAjaxBean.upImage.getBytes}"/>
> > >
> > >  So the URL would just have :
> > >  - The initializationParameters
> > >  - The viewId
> > >  - The componentId
> > >
> > >
> > >  On Wed, 2005-09-28 at 16:12 -0400, Mike Kienenberger wrote:
> > >  Yes, I think you're right in that the size of the image doesn't matter.
> > > However, the size of my page's jsf_state_64 attribute does matter.
> > > The page I'm looking at right this second has a jsf_state_64 of 3,768
> > > bytes.
> > >
> > > No, I didn't try this with the sandbox since it seemed easy enough to
> > > just dump it into my own application (and it was).
> > >
> > > I did some investigating, and the URL limit in Jetty is hardcoded to
> > > 4096 bytes. I also noticed that this error (414 Url too large) is a
> > > standard http protocol error, so it's reasonable to think that other
> > > servers are going to throw it.
> > >
> > > On 9/28/05, Sylvain Vieujot <svieujot@apache.org> wrote:
> > > > Except if you serialize the image, the size of the image shouldn't be
a
> > > > factor.
> > > > Did you try this with the sandbox application ?
> > > > Do you know the URL size limit in Jetty ?
> > > >
> > > > Thanks,
> > > >
> > > > Sylvain.
> > > >
> > > >
> > > > On Wed, 2005-09-28 at 15:30 -0400, Mike Kienenberger wrote:
> > > > Well, the url is also a problem with some containers.
> > > >
> > > > Jetty 5.1.3 is generating this error:
> > > >
> > > > 15:28:58.609 WARN!! [SocketListener0-1]
> > > >
> > > org.mortbay.http.HttpConnection.exception(HttpConnection.java:762)
> > > > >06> null
> > > /faces/pages/announcement/EditAnnouncements.xhtml
> > > > HTTP/1.1
> > > > HttpException(414,Request URI Too Large,null)
> > > >
> > > > and this is with a small (13,342 byte) image. Well, relatively small :)
> > > >
> > > > On 9/28/05, Sylvain Vieujot <svieujot@apache.org> wrote:
> > > > > As for the URL limitation, this can indeed be a problem, but not
@ 1024
> > > > > chars.
> > > > > There is no spec limiting the number of chars in the URL, but browsers
> > > can
> > > > > have problems :
> > > > > http://www.aspfaq.com/show.asp?id=2222
> > > > >
> > > > > But, as I didn't find any way to use a post request to load an image,
I
> > > > see
> > > > > no workaround for this.
> > > > > We'll just have to experiment if in real life it causes really problems,
> > > > > and put a warning on this.
> > > > >
> > > > > About your phase listener comment, could you send me a patch for
this ?
> > > > >
> > > > > Thanks !
> > > > >
> > > > > Sylvain.
> > > > >
> > > > >
> > > > > On Wed, 2005-09-28 at 10:06 +0200, Mathias Brökelmann wrote:
> > > > > Great! We definitely need a component to render dynamic images.
> > > > >
> > > > > I took a view into the code and saw that the state is appended to
the
> > > > > image url. IMO it will not work in every case since the state could
be
> > > > > very large and as far as I know there is a limitation around 1024
> > > > > chars in a request url.
> > > > >
> > > > > The other thing is the phase listener which will not work if the
> > > > > component is used in a uidata component. Try using a custom faces
> > > > > event which is queued through UIComponent.queueEvent(...).
> > > > >
> > > > >
> > > > > 2005/9/28, Sylvain Vieujot <svieujot@apache.org>:
> > > > > > I just committed a first working version of a graphicImage component
> > > > that
> > > > > > displays the images from bytes, and that doesn't need an additional
> > > > > servlet.
> > > > > >
> > > > > > It works, but there is still work to be done (See the TODOs
in the
> > > > > > component's java file).
> > > > > >
> > > > > > The most important things are :
> > > > > > 1) Find a good name for this component. Right now, it says Ajax
> > > whereas
> > > > > > it's not really Ajax.
> > > > > > 2) Extend it to make download links (uses an <a> instead
of an <img>
> > > > > >
> > > > > > Thanks for your ideas,
> > > > > >
> > > > > > Sylvain.
> > > > > >
> > > > > > On Tue, 2005-09-27 at 12:35 -0400, Mike Kienenberger wrote:
> > > > > > Sylvain,
> > > > > >
> > > > > > I'm definitely interested in a component that can display an
image
> > > > > > from bytes as well, if you want any assistance.
> > > > > >
> > > > > > "-- need a dynamic image servlet" is the next item on my todo
list :)
> > > > > >
> > > > > > On 9/26/05, Sylvain Vieujot <svieujot@apache.org> wrote:
> > > > > > > Yes, you're right, but I was looking for a way to use the
same code
> > > > with
> > > > > a
> > > > > > > get request instead of a post request.
> > > > > > > So, I think this will work.
> > > > > > >
> > > > > > > I'll post this soon so that you can check it.
> > > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > Sylvain.
> > > > > > >
> > > > > > >
> > > > > > > On Mon, 2005-09-26 at 23:24 +0200, Martin Marinschek wrote:
> > > > > > > The snippet you posted is just about remembering the state
of the
> > > > > > > application client side - it doesn't have to do anything
with
> > > dynamic
> > > > > > > loading of images...
> > > > > > >
> > > > > > > Or do I get you completely wrong?
> > > > > > >
> > > > > > > regards,
> > > > > > >
> > > > > > > Martin
> > > > > > >
> > > > > > > On 9/26/05, Sylvain Vieujot <svieujot@apache.org>
wrote:
> > > > > > > > You're right, Ajax isn't the perfect term for this,
as the result
> > > > > won't
> > > > > > be
> > > > > > > > XML.
> > > > > > > >
> > > > > > > > But maybe it can work using something similar to that
:
> > > > > > > > " callback: function(element,entry) {return
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > entry+'&jsf_tree_64='+encodeURIComponent(document.getElementById('jsf_tree_64').value)+'&jsf_state_64='+encodeURIComponent(document.getElementById('jsf_state_64').value)+'&jsf_viewid='+encodeURIComponent(document.getElementById('jsf_viewid').value)}"
> > > > > > > > +
> > > > > > > >
> > > > > > > > (extracted from the inputSuggestAjax code).
> > > > > > > >
> > > > > > > > Thanks for the clue.
> > > > > > > >
> > > > > > > > Sylvain.
> > > > > > > >
> > > > > > > >
> > > > > > > > On Mon, 2005-09-26 at 16:27 -0400, Matt Blum wrote:
> > > > > > > >
> > > > > > > > The XMLHttpRequest object (or the equivalent ActiveX
control)'s
> > > open
> > > > > > > method
> > > > > > > > takes as its first argument the request method you
want to use. So
> > > > you
> > > > > > > > could make a get request simply by saying:
> > > > > > > >
> > > > > > > > xHR.open("GET", url[, asyncflag][, username][, password]);
> > > > > > > >
> > > > > > > > I believe that answers your question, but I'm not
sure I
> > > understand
> > > > > how
> > > > > > > > that helps you. I mean, AJAX will return a text string,
and
> > > possibly
> > > > a
> > > > > > > > document object if the response is valid XML. It won't
return an
> > > > > image.
> > > > > > > > The only way to load an image is, as you say, using
the src
> > > property
> > > > > of
> > > > > > > the
> > > > > > > > image object, and that will always do a GET. I don't
see how you
> > > get
> > > > > > AJAX
> > > > > > > > to work into this scenario, unless you plan to use
it to generate
> > > > the
> > > > > > URL
> > > > > > > > for the image object to load.
> > > > > > > >
> > > > > > > > Or am I just missing something in your original message?
> > > > > > > >
> > > > > > > > -Matt
> > > > > > > >
> > > > > > > >
> > > > > > > > On 9/26/05, Sylvain Vieujot <svieujot@apache.org>
wrote:
> > > > > > > >
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > I'm trying to make a new component that would display
an image,
> > > but
> > > > > > > without
> > > > > > > > the need to have a dedicated servlet.
> > > > > > > > It would make applications that use images from a
lot of different
> > > > > > sources
> > > > > > > > (i.e. servlets) much simpler.
> > > > > > > > Basically, it would be a component like :
> > > > > > > > <x:graphicImageAjax getBytesMethod="#{myBean.imageBytes}"/>
> > > > > > > >
> > > > > > > > As the only way I found to load an image in javascript
is
> > > > > > image.src="...",
> > > > > > > > I can't use a post request.
> > > > > > > >
> > > > > > > > Does someone know a way either to load an image in
javascript with
> > > > the
> > > > > > > > result of a post request, or a way to use ajax like
in
> > > > > inputSuggestAjax,
> > > > > > > but
> > > > > > > > with a get url ?
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > >
> > > > > > > > Sylvain.
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > http://www.irian.at
> > > > > > > Your JSF powerhouse -
> > > > > > > JSF Trainings in English and German
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Mathias
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >

Mime
View raw message