You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Eelco Hillenius <ee...@gmail.com> on 2006/10/11 16:39:48 UTC
externalizing state by components
Triggered by that question earlier this week about how to externalize
the urls of a pageable list, I thought a little bit about
externalizing state by components.
I think with Wicket 2.0, we got a bit closer to being able to do that,
as we can traverse the whole hierarchy after creation.
RequestCycle#urlFor (or any of the delegates) could for instance
traverse all components, and look for an annotation like this:
public class SomePagingComponent extends Blah {
...
@UrlEncoded private transient int pageNbr = 1;
}
Which would work with to string by default, and additionally,
components could implement an interface to customize this:
public interface ParameterUrlEncoder {
CharSequence encode(String propertyName);
void decode(String propertyName, String encodedValue);
}
The mechanism (somewhere in urlFor calls) could take care of the
proper naming/scoping of variables, and could compress (and later
decompress) the total contributed part of the URL. The request
resolving part of the request cycle handling, should then inject the
state again.
Maybe (probably) I'm overlooking something, but I think this is
feasible and actually not that hard to achieve. I think it would be
VERY nice to have this, not only for bookmarkability without having
having to give up on component scoped programming model, but also for
scalability, where you can decide to use stateless pages with
components like this (which could in many cases be stateless too).
The main problem we would have is what to do with URLs that exceed the
max lenght (which btw does not seems to fixed on 255 as I always
thought, though 255 is recommended as a safe - but maybe outdated -
upper limit, but I have seen 2048 and higher mentioned as well). The
obvious thing to do is - like .NET and JSF - convert all gets to
POSTs, but that gets really messy to implement (though due to our
redirecting for renderings, users shouldn't notice).
WDYT, anyone wants to give this a go?
Eelco
Re: externalizing state by components
Posted by Igor Vaynberg <ig...@gmail.com>.
i dont know - how do you decide if something is stateless?
what if i have a component where everything is annotated, then that
component is extended by another one where things are not annotated....?
-Igor
On 10/11/06, Eelco Hillenius <ee...@gmail.com> wrote:
>
> On 10/11/06, Igor Vaynberg <ig...@gmail.com> wrote:
> > so what happens if you have a component that supports it and a component
> > that doesnt?
> >
> > you go to this bookmarkable url and only the component that supported
> param
> > externalization has its state restored, the other one starts new?
>
> No, it would work just like you can have stateless and normal
> components mixed now, and a page is not stateless unless everything
> nested in it is stateless. Components that are externalizable are not
> automatically stateless, though they typically could be. But as long
> as there are statefull components on the page, the parameters are put
> in the url etc, but the page is still internal.
>
> Eelco
>
Re: externalizing state by components
Posted by Johan Compagner <jc...@gmail.com>.
ahh now your are making sense to me because this above:
No this externalizable thing only means that 'state' is being passed
as part of the URL. So an URL like this
http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:
could be something like
http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:&wicket:state=dfskajkladsjf676sdfa
didn't make any sense to me.
Because that will be a statefull component what ever the cost so that wicket
state after a wicket:interface only thing
is completely redundant because that state will be there no matter what. Or
are you saying that we are detaching
(setting all the fields to null) where we make the state from?
stateless components have both so something like this:
http://localhost:8081/tsp/web/my/mout<http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:&wicket:state=dfskajkladsjf676sdfa>
?wicket:interface=_wf_component:1:10:1:<http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:&wicket:state=dfskajkladsjf676sdfa>
or
http://localhost:8081/tsp/web<http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:&wicket:state=dfskajkladsjf676sdfa>
?wicket:bookmarkablePage=xxxxx&wicket:interface=_wf_component:1:10:1:<http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:&wicket:state=dfskajkladsjf676sdfa>
after these urls we could push the wicket:state
and if we then can't connect to the wicket:interface part but only to the
bookmarkable part we can push the state back in again.
johan
On 10/11/06, Eelco Hillenius <ee...@gmail.com> wrote:
>
> I'd like to chip in here to state that by what I proposed I don't want
> to make Wicket suddenly a stateless framework or something. I'm
> primarily looking for scalability optimizations. We made a step in the
> right direction with stateless pages/ forms/ links, but the next step
> nice step on top of this is to be able to make these stateless
> components partially statefull again by declaring the fields that
> should be externalized. If we keep it simple - never try to magically
> transform to posts - I think it's doable and even quite elegant. It
> would actually give us a Tapestry-like programming model, but then
> with Wicket's flexibility and the option of mixing the programming
> models.
>
> As an extra, combined with URL mounting, it would be a bit easier to
> create pages with nice URLs, because rather than having to fall back
> on coding to the page level people have to do now, people could use
> bookmarkable pages and components to push out state to keep the scope
> and state on a component level, while still achieving bookmarkability.
>
> I think it's worth to take a look, and honestly, I don't even think
> it'll be that difficult for Wicket 2.0
>
> Eelco
>
Re: externalizing state by components
Posted by Eelco Hillenius <ee...@gmail.com>.
> What you're proposing sounds good to me (a complete novice, I must
> emphasise), but I think you hit the nail on the head there. Wicket is
> fantastic for the work I'm doing precisely because it /is/ stateful.
> I'd hate to see wicket going down the route of obsessing over the
> reduction of server-side state management, because it'd lose a lot of
> its appeal in the process.
I agree. So what I'm thinking of is - like stateless pages and url
mounting is now - something optionally; people can decide for
themselves if they want to go through the extra effort to do this, but
by default the programming models stays as it is now.
Eelco
Re: externalizing state by components
Posted by Paul Russell <pa...@luminas.co.uk>.
On 11 Oct 2006, at 21:13, Eelco Hillenius wrote:
>> I'm not really clear how responsibility /can/ be delegated to the
>> components? Would they just serialize the model into the URL? Can't
>> help thinking this would lead to some seriously long URLs, even for
>> detachable models (class name has to be in there, for a start).
> It would work like I started my email with.
>
> It is not my intention to serialize all state of the components/
> models. This is the 'brute force' approach of JSF and .NET (yes I know
> somewhere down the line it is probably somehow configurable :) ).
> Stateless components currently just don't keep any state you put in
> them. Much like .NET or Tapestry where you can put all the variables
> you want in the pages, but the page will be recreated on each call.
> State you want to transfer must be put in ViewState (.NET), or
> configured/ annotated (Tapestry). This optional state thingy is
> something I'm proposing here for Wicket.
Ahh, right, I'm with you. I'm totally in agreement that brute force
serialisation is a bad plan -- I was thinking more of serializing the
'state' of detachable models, but you're right, that should be
reconstructable when the new request comes in anyway, since we're
talking primarily about static information like property resolver
paths etc.
P.
Re: externalizing state by components
Posted by Eelco Hillenius <ee...@gmail.com>.
> On 11 Oct 2006, at 20:34, Eelco Hillenius wrote:
> > Hmmm. Yeah, that's an interesting choice to make. Is it the
> > responsiblity of models, or components. There is some logic to using
> > models, but I'm afraid things get really messy quickly then.
> > Components are the entity which know whether they are stateless or
> > not, and I think it is components that you would design specifically
> > for this purpose, not models. And however important models are in the
> > total scope of developing Wicket applications, they are subject to
> > components, which may - and often do - decide not to use models or
> > just partially (like the pageable list which uses a normal member for
> > the current page number).
>
> I'm not really clear how responsibility /can/ be delegated to the
> components? Would they just serialize the model into the URL? Can't
> help thinking this would lead to some seriously long URLs, even for
> detachable models (class name has to be in there, for a start).
It would work like I started my email with.
It is not my intention to serialize all state of the components/
models. This is the 'brute force' approach of JSF and .NET (yes I know
somewhere down the line it is probably somehow configurable :) ).
Stateless components currently just don't keep any state you put in
them. Much like .NET or Tapestry where you can put all the variables
you want in the pages, but the page will be recreated on each call.
State you want to transfer must be put in ViewState (.NET), or
configured/ annotated (Tapestry). This optional state thingy is
something I'm proposing here for Wicket.
Eelco
Re: externalizing state by components
Posted by Paul Russell <pa...@luminas.co.uk>.
On 11 Oct 2006, at 20:21, Martijn Dashorst wrote:
> Yep, this is something we all are trying to achieve... The same old
> purty framework, but with additional options to service the needy
> greedy :-)
Phew.
> I could envision an IEncodableModel interface:
>
> interface IEncodableModel {
> PageParameters encodeState();
> void decodeState(PageParameters parameters);
> }
That sounds fantastic. I guess a similar interface could be used by
the component to externalise its intrinsic state (visble/invisible
etc)? How would the component hierarchy itself be reconstructed?
On 11 Oct 2006, at 20:34, Eelco Hillenius wrote:
> Hmmm. Yeah, that's an interesting choice to make. Is it the
> responsiblity of models, or components. There is some logic to using
> models, but I'm afraid things get really messy quickly then.
> Components are the entity which know whether they are stateless or
> not, and I think it is components that you would design specifically
> for this purpose, not models. And however important models are in the
> total scope of developing Wicket applications, they are subject to
> components, which may - and often do - decide not to use models or
> just partially (like the pageable list which uses a normal member for
> the current page number).
I'm not really clear how responsibility /can/ be delegated to the
components? Would they just serialize the model into the URL? Can't
help thinking this would lead to some seriously long URLs, even for
detachable models (class name has to be in there, for a start).
Sorry if I'm asking stupid questions, but I'm trying to get up to
speed with the internals -- if I'm taking up too much of you guys
time, please do tell me to belt up, and I'll just watch instead!
P.
Re: Re: externalizing state by components
Posted by Eelco Hillenius <ee...@gmail.com>.
Hmmm. Yeah, that's an interesting choice to make. Is it the
responsiblity of models, or components. There is some logic to using
models, but I'm afraid things get really messy quickly then.
Components are the entity which know whether they are stateless or
not, and I think it is components that you would design specifically
for this purpose, not models. And however important models are in the
total scope of developing Wicket applications, they are subject to
components, which may - and often do - decide not to use models or
just partially (like the pageable list which uses a normal member for
the current page number).
Eelco
On 10/11/06, Martijn Dashorst <ma...@gmail.com> wrote:
> Yep, this is something we all are trying to achieve... The same old
> purty framework, but with additional options to service the needy
> greedy :-)
>
> I could envision an IEncodableModel interface:
>
> interface IEncodableModel {
> PageParameters encodeState();
> void decodeState(PageParameters parameters);
> }
>
> that would externalize its state into the page parameters, which can
> be added to the component listener thing. Sort of a detachable model,
> but then storing its state into the request url, instead of the
> session.
>
> I'm not sure this would help in any way, but I'll have it process in
> my background...
>
> Martijn
>
> On 10/11/06, Paul Russell <pa...@luminas.co.uk> wrote:
> > On 11 Oct 2006, at 20:06, Eelco Hillenius wrote:
> > > I'd like to chip in here to state that by what I proposed I don't want
> > > to make Wicket suddenly a stateless framework or something.
> >
> > What you're proposing sounds good to me (a complete novice, I must
> > emphasise), but I think you hit the nail on the head there. Wicket is
> > fantastic for the work I'm doing precisely because it /is/ stateful.
> > I'd hate to see wicket going down the route of obsessing over the
> > reduction of server-side state management, because it'd lose a lot of
> > its appeal in the process.
> >
> > Thanks,
> >
> >
> > Paul
> >
>
>
> --
> <a href="http://www.thebeststuffintheworld.com/vote_for/wicket">Vote</a>
> for <a href="http://www.thebeststuffintheworld.com/stuff/wicket">Wicket</a>
> at the <a href="http://www.thebeststuffintheworld.com/">Best Stuff in
> the World!</a>
>
Re: Re: externalizing state by components
Posted by Martijn Dashorst <ma...@gmail.com>.
Yep, this is something we all are trying to achieve... The same old
purty framework, but with additional options to service the needy
greedy :-)
I could envision an IEncodableModel interface:
interface IEncodableModel {
PageParameters encodeState();
void decodeState(PageParameters parameters);
}
that would externalize its state into the page parameters, which can
be added to the component listener thing. Sort of a detachable model,
but then storing its state into the request url, instead of the
session.
I'm not sure this would help in any way, but I'll have it process in
my background...
Martijn
On 10/11/06, Paul Russell <pa...@luminas.co.uk> wrote:
> On 11 Oct 2006, at 20:06, Eelco Hillenius wrote:
> > I'd like to chip in here to state that by what I proposed I don't want
> > to make Wicket suddenly a stateless framework or something.
>
> What you're proposing sounds good to me (a complete novice, I must
> emphasise), but I think you hit the nail on the head there. Wicket is
> fantastic for the work I'm doing precisely because it /is/ stateful.
> I'd hate to see wicket going down the route of obsessing over the
> reduction of server-side state management, because it'd lose a lot of
> its appeal in the process.
>
> Thanks,
>
>
> Paul
>
--
<a href="http://www.thebeststuffintheworld.com/vote_for/wicket">Vote</a>
for <a href="http://www.thebeststuffintheworld.com/stuff/wicket">Wicket</a>
at the <a href="http://www.thebeststuffintheworld.com/">Best Stuff in
the World!</a>
Re: externalizing state by components
Posted by Paul Russell <pa...@luminas.co.uk>.
On 11 Oct 2006, at 20:06, Eelco Hillenius wrote:
> I'd like to chip in here to state that by what I proposed I don't want
> to make Wicket suddenly a stateless framework or something.
What you're proposing sounds good to me (a complete novice, I must
emphasise), but I think you hit the nail on the head there. Wicket is
fantastic for the work I'm doing precisely because it /is/ stateful.
I'd hate to see wicket going down the route of obsessing over the
reduction of server-side state management, because it'd lose a lot of
its appeal in the process.
Thanks,
Paul
Re: externalizing state by components
Posted by Eelco Hillenius <ee...@gmail.com>.
I'd like to chip in here to state that by what I proposed I don't want
to make Wicket suddenly a stateless framework or something. I'm
primarily looking for scalability optimizations. We made a step in the
right direction with stateless pages/ forms/ links, but the next step
nice step on top of this is to be able to make these stateless
components partially statefull again by declaring the fields that
should be externalized. If we keep it simple - never try to magically
transform to posts - I think it's doable and even quite elegant. It
would actually give us a Tapestry-like programming model, but then
with Wicket's flexibility and the option of mixing the programming
models.
As an extra, combined with URL mounting, it would be a bit easier to
create pages with nice URLs, because rather than having to fall back
on coding to the page level people have to do now, people could use
bookmarkable pages and components to push out state to keep the scope
and state on a component level, while still achieving bookmarkability.
I think it's worth to take a look, and honestly, I don't even think
it'll be that difficult for Wicket 2.0
Eelco
Re: externalizing state by components
Posted by Igor Vaynberg <ig...@gmail.com>.
On 10/11/06, Korbinian Bachl <ko...@whiskyworld.de> wrote:
>
> Hi,
>
> i hope its ok to hok me in, even if im new to wicket and not one of the
> developers.
anyone and everyone are welcome
With nice URLs you have following advantages:
>
> * Since all requests are routed through a single servlet (typically
> mapped to /app), J2EE declarative security, which is path-based, is
> defeated.
you are free to use page mounting to alter the path if you want to use
declarative security. noting that this security model is built for old style
model 1/2 apps and wicket has a much more powerful model for security.
* Ugly URLs tend to be longer than friendly URLs, which can make a
> difference when creating a WML application.
this is completely and utterly false. because wicket does not rely on
parameter encoding in the url its urls are usually shorter.
?wicket:interface=10:some.path.to.comp:5
is a lot shorter then if you keep the state on the url
/books.do?sort1=up&sort2=down&sort3=none&page=4&filter.name=%bob%&filter.agelt=30&filter.agegt=45
furthermore if you turn on urlcompressor your urls will always be
?wicket:interface=a:b:c where a,b,c are ints, so ?wicket:interface=10:32:4
* A single directory may contain all the artifacts (HTML templates,
> specifications, properties files) for all the pages in an entire
> application. There isn't a sanctioned approach to organizing things into
> subdirectories.
wicket doesnt work with directories, it works with packages. you are free to
organize your static resources any way you like.
* The reliance on query parameters means that common search engines will
> only see a tiny fraction of the application.
the jury on this one is still out. google has plenty urls in it with
?jsessionid var so it must be indexing those.
wicket is not the best tech to do this because it is stateful by default. so
if you need this type of thing you need to build that portion of your app
using stateless pages only.
Plus (!) the important security feature that your technology is not revealed
> to the outer world, making attacks on it mor difficult (if your url is
>
> http://127.0.0.1:8080/WhiskyworldV6-war?wicket:interface=:0:pagination:navig
> ation:1:pageLink::ILinkListener its easy to know that wicket is used, and
> its a JEE server then...)
heh. well you know its wicket. so? there are plenty of .do struts apps out
there. security by obfuscation is not the greatest thing to do anyways.
what you are missing is that wicket is by far much much much more secure
then other frameworks because all urls in wicket are session-relative(!). so
unless someone manages to hijack a session there is really nothing they can
do. and even then the urls are always changing(!) even if they are pointing
to the same action, so that makes it even harder to for someone to do
anything.
furthermore we have a crypt-url-encoding-strategy that can encrypt the urls.
For me, the big question is
>
> a, why do we need state all time? - and if we have a state, cant it be
> serialized ? (e.g: parameters?)
because by assuming everything is stateful all the time we make coding
satateful components easy(!) - and this is the most important goal of
wicket.
b, if we neednt state all time, why cant this be translated to a nice link?
it can - see bookmarkable pages and page mounting
-Igor
Re: AW: externalizing state by components
Posted by Eelco Hillenius <ee...@gmail.com>.
> im not sure on this one. If every component may be hooked to a unique URL
> Part, then it wont matter at what location it is, would it?
>
> I mean i use the bookmarkable system we have and just transfer it to the
> components.
>
> e.g: Component A = mounted to(/A)
> Component B = mounted to (/B)
> Component C = mounted to (/C)
>
> if a page now is called using /page/a/12/b/13
This is going towards a string based approach like e.g. model 2
frameworks work. Wicket is based around Java objects, not strings, for
it's state and it is uses components, rather than actions.
Furthermore, components live in a tree, with one root component, Page.
The fact that components live in such a hierarchy makes that they can
cooperate with each other in an easy fashion, traverse their children,
etc. This is very fundamental for Wicket, and thus mounting separate
components cannot be supported.
Eelco
AW: AW: externalizing state by components
Posted by Korbinian Bachl <ko...@whiskyworld.de>.
Hi Matej,
im not sure on this one. If every component may be hooked to a unique URL
Part, then it wont matter at what location it is, would it?
I mean i use the bookmarkable system we have and just transfer it to the
components.
e.g: Component A = mounted to(/A)
Component B = mounted to (/B)
Component C = mounted to (/C)
if a page now is called using /page/a/12/b/13
it knows that A gets a string "12" - but if a is not incorporated it does
nothing - and if there is a component A it gets it - if there is A + B A
gets 12, B 13, if there is only B it gets 13 - rest is just ignored, so why
cant you switch then??? The hirarchy doesnt count, as it wouldnt matter to
what A is linked as long as its any component
The par with the map, is something i dont understand properly. What do you
store in there ? And why does the instance count?
Regards
> -----Ursprüngliche Nachricht-----
> Von: Matej Knopp [mailto:matej@knopp.sk]
> Gesendet: Mittwoch, 11. Oktober 2006 20:28
> An: wicket-dev@incubator.apache.org
> Betreff: Re: AW: externalizing state by components
>
> I'm affraid something like this would not work, at least not
> without major changes in Wicket. You're making assumption
> that component hierarchy is static and predictable. But
> that's not. Components on page can change. Every request you
> can change component hierarchy. Therefore you need page id in
> the request (page id is used to get page instance from page map).
>
> The state of page is more than just a couple of component
> properties. It is the whole component structure.
>
> -Matej
>
> Korbinian Bachl wrote:
> > Hi,
> >
> > i hope its ok to hok me in, even if im new to wicket and not one of
> > the developers.
> >
> > I think i lead eelco this way, regarding nice URLs.
> >
> > With nice URLs you have following advantages:
> >
> > * Since all requests are routed through a single servlet
> > (typically mapped to /app), J2EE declarative security, which is
> > path-based, is defeated.
> > * Ugly URLs tend to be longer than friendly URLs, which
> can make a
> > difference when creating a WML application.
> > * A single directory may contain all the artifacts (HTML
> > templates, specifications, properties files) for all the
> pages in an
> > entire application. There isn't a sanctioned approach to organizing
> > things into subdirectories.
> > * The reliance on query parameters means that common search
> > engines will only see a tiny fraction of the application.
> >
> > Plus (!) the important security feature that your technology is not
> > revealed to the outer world, making attacks on it mor difficult (if
> > your url is
> >
> http://127.0.0.1:8080/WhiskyworldV6-war?wicket:interface=:0:pagination
> > :navig ation:1:pageLink::ILinkListener its easy to know
> that wicket is
> > used, and its a JEE server then...)
> >
> > For me, the big question is
> >
> > a, why do we need state all time? - and if we have a state,
> cant it be
> > serialized ? (e.g: parameters?) b, if we neednt state all time, why
> > cant this be translated to a nice link?
> >
> > at least, when wicket creates a link it has to know (!)
> where it ends,
> > meaning that it shouldnt be a difference if its used /link/a or
> > ?wicket:interface=.... ending both in same actions. So, if wicket
> > knows where the link goes to, and what it transports, why
> cant this be
> > formed well then?
> >
> > e.g:
> >
> > Page: Index
> > has component: SearchfieldComp
> > has component: FooterComp
> > (footer has component UselessComp)
> >
> > we need nothing but a link to /Index
> >
> > if now UselessComp has a state like UselessThing is String
> "thing" it
> > could be a link to /Index/thing
> >
> > Why? because its the first thing in the URL after the
> Index/ - and its
> > the first thing the component would need and UselessComp gets it
> > because its the first component that needs sth.
> >
> > if now SearchField also contains a String "Foo" it would then be:
> > /Index/Foo/thing
> >
> > now we only have the problem that we dont know if wether
> Searchfield
> > gets Foo or thing (1st example)
> >
> > the soluton would be to encode the component name itself
> and to give
> > the developer the chance to alter this name e.g: same as we do with
> > mount for pages, we could do this for Components
> >
> > e.g:
> > Page: Index
> > has component: SearchfieldComp (mounted to LOOK) has component:
> > FooterComp (mounted to nothing as it never gets anything)
> (footer has
> > component UselessComp) (mounted to USELESS)
> >
> > -> solutionlink: /Index/LOOK/Foo/USELESS/thing
> >
> > this would be the key solution - if the wicket user needs
> nice URL he
> > gets the maximum possibility to alter the names if not, he
> gets ugly
> > URLs like before.
> >
> > This means, if we also provide names to components (the
> ability) then
> > we clould also unify bookmarkable link as well as link as
> it wouldnt
> > matter what kind we have, we would only check if all
> components nested
> > in that page have names, if not -> ugly URL, if they have
> -> nice URL !
> >
> > now, wouldnt this be a solution worth digging in???
> >
> > Best Regards,
> >
> > Korbinian
> >
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Eelco Hillenius [mailto:eelco.hillenius@gmail.com]
> >> Gesendet: Mittwoch, 11. Oktober 2006 19:00
> >> An: wicket-dev@incubator.apache.org
> >> Betreff: Re: externalizing state by components
> >>
> >> On 10/11/06, Frank Bille <fr...@gmail.com> wrote:
> >>> But shouldn't the page be bookmarkable then? How else are
> >> you going to
> >>> make use of that externalized component? Except if I have
> got your
> >>> concept of "externalizing" wrong (= bookmarkable)
> >> No this externalizable thing only means that 'state' is
> being passed
> >> as part of the URL. So an URL like this
> >>
> >>
> http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:
> >>
> >> could be something like
> >>
> >> http://localhost:8081/tsp/web?wicket:interface=_wf_component:1
> >> :10:1:&wicket:state=dfskajkladsjf676sdfa
> >>
> >> where that state is an encoded set of parameters. That
> encoding could
> >> be overridden to make them look nice (but less
> >> efficient) on a component basis (ParameterUrlEncoder), so that it
> >> could look like
> >>
> >> http://someserver/foo/bar/books/Brave_New_World
> >>
> >> Where books,Brave_New_World is what is contributed by the
> component,
> >> and points to a bookmarkable page mounted at /bar/books.
> >>
> >> Also: please note that I'm still thinking about this. It would be
> >> more helpful to think with me how we could pull this off,
> then to try
> >> to find things why it couldn't work. IMO, if we can
> implement this,
> >> it would be a huge potential improvement in our scalability and
> >> bookmarkability options.
> >>
> >> Eelco
> >>
> >
> >
>
>
Re: AW: externalizing state by components
Posted by Matej Knopp <ma...@knopp.sk>.
I'm affraid something like this would not work, at least not without
major changes in Wicket. You're making assumption that component
hierarchy is static and predictable. But that's not. Components on page
can change. Every request you can change component hierarchy. Therefore
you need page id in the request (page id is used to get page instance
from page map).
The state of page is more than just a couple of component properties. It
is the whole component structure.
-Matej
Korbinian Bachl wrote:
> Hi,
>
> i hope its ok to hok me in, even if im new to wicket and not one of the
> developers.
>
> I think i lead eelco this way, regarding nice URLs.
>
> With nice URLs you have following advantages:
>
> * Since all requests are routed through a single servlet (typically
> mapped to /app), J2EE declarative security, which is path-based, is
> defeated.
> * Ugly URLs tend to be longer than friendly URLs, which can make a
> difference when creating a WML application.
> * A single directory may contain all the artifacts (HTML templates,
> specifications, properties files) for all the pages in an entire
> application. There isn't a sanctioned approach to organizing things into
> subdirectories.
> * The reliance on query parameters means that common search engines will
> only see a tiny fraction of the application.
>
> Plus (!) the important security feature that your technology is not revealed
> to the outer world, making attacks on it mor difficult (if your url is
> http://127.0.0.1:8080/WhiskyworldV6-war?wicket:interface=:0:pagination:navig
> ation:1:pageLink::ILinkListener its easy to know that wicket is used, and
> its a JEE server then...)
>
> For me, the big question is
>
> a, why do we need state all time? - and if we have a state, cant it be
> serialized ? (e.g: parameters?)
> b, if we neednt state all time, why cant this be translated to a nice link?
>
> at least, when wicket creates a link it has to know (!) where it ends,
> meaning that it shouldnt be a difference if its used /link/a or
> ?wicket:interface=.... ending both in same actions. So, if wicket knows
> where the link goes to, and what it transports, why cant this be formed well
> then?
>
> e.g:
>
> Page: Index
> has component: SearchfieldComp
> has component: FooterComp
> (footer has component UselessComp)
>
> we need nothing but a link to /Index
>
> if now UselessComp has a state like UselessThing is String "thing" it could
> be a link to /Index/thing
>
> Why? because its the first thing in the URL after the Index/ - and its the
> first thing the component would need and UselessComp gets it because its the
> first component that needs sth.
>
> if now SearchField also contains a String "Foo" it would then be:
> /Index/Foo/thing
>
> now we only have the problem that we dont know if wether Searchfield gets
> Foo or thing (1st example)
>
> the soluton would be to encode the component name itself and to give the
> developer the chance to alter this name e.g: same as we do with mount for
> pages, we could do this for Components
>
> e.g:
> Page: Index
> has component: SearchfieldComp (mounted to LOOK)
> has component: FooterComp (mounted to nothing as it never gets anything)
> (footer has component UselessComp) (mounted to USELESS)
>
> -> solutionlink: /Index/LOOK/Foo/USELESS/thing
>
> this would be the key solution - if the wicket user needs nice URL he gets
> the maximum possibility to alter the names if not, he gets ugly URLs like
> before.
>
> This means, if we also provide names to components (the ability) then we
> clould also unify bookmarkable link as well as link as it wouldnt matter
> what kind we have, we would only check if all components nested in that page
> have names, if not -> ugly URL, if they have -> nice URL !
>
> now, wouldnt this be a solution worth digging in???
>
> Best Regards,
>
> Korbinian
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: Eelco Hillenius [mailto:eelco.hillenius@gmail.com]
>> Gesendet: Mittwoch, 11. Oktober 2006 19:00
>> An: wicket-dev@incubator.apache.org
>> Betreff: Re: externalizing state by components
>>
>> On 10/11/06, Frank Bille <fr...@gmail.com> wrote:
>>> But shouldn't the page be bookmarkable then? How else are
>> you going to
>>> make use of that externalized component? Except if I have got your
>>> concept of "externalizing" wrong (= bookmarkable)
>> No this externalizable thing only means that 'state' is being
>> passed as part of the URL. So an URL like this
>>
>> http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:
>>
>> could be something like
>>
>> http://localhost:8081/tsp/web?wicket:interface=_wf_component:1
>> :10:1:&wicket:state=dfskajkladsjf676sdfa
>>
>> where that state is an encoded set of parameters. That
>> encoding could be overridden to make them look nice (but less
>> efficient) on a component basis (ParameterUrlEncoder), so
>> that it could look like
>>
>> http://someserver/foo/bar/books/Brave_New_World
>>
>> Where books,Brave_New_World is what is contributed by the
>> component, and points to a bookmarkable page mounted at /bar/books.
>>
>> Also: please note that I'm still thinking about this. It
>> would be more helpful to think with me how we could pull this
>> off, then to try to find things why it couldn't work. IMO, if
>> we can implement this, it would be a huge potential
>> improvement in our scalability and bookmarkability options.
>>
>> Eelco
>>
>
>
AW: externalizing state by components
Posted by Korbinian Bachl <ko...@whiskyworld.de>.
Hi,
i hope its ok to hok me in, even if im new to wicket and not one of the
developers.
I think i lead eelco this way, regarding nice URLs.
With nice URLs you have following advantages:
* Since all requests are routed through a single servlet (typically
mapped to /app), J2EE declarative security, which is path-based, is
defeated.
* Ugly URLs tend to be longer than friendly URLs, which can make a
difference when creating a WML application.
* A single directory may contain all the artifacts (HTML templates,
specifications, properties files) for all the pages in an entire
application. There isn't a sanctioned approach to organizing things into
subdirectories.
* The reliance on query parameters means that common search engines will
only see a tiny fraction of the application.
Plus (!) the important security feature that your technology is not revealed
to the outer world, making attacks on it mor difficult (if your url is
http://127.0.0.1:8080/WhiskyworldV6-war?wicket:interface=:0:pagination:navig
ation:1:pageLink::ILinkListener its easy to know that wicket is used, and
its a JEE server then...)
For me, the big question is
a, why do we need state all time? - and if we have a state, cant it be
serialized ? (e.g: parameters?)
b, if we neednt state all time, why cant this be translated to a nice link?
at least, when wicket creates a link it has to know (!) where it ends,
meaning that it shouldnt be a difference if its used /link/a or
?wicket:interface=.... ending both in same actions. So, if wicket knows
where the link goes to, and what it transports, why cant this be formed well
then?
e.g:
Page: Index
has component: SearchfieldComp
has component: FooterComp
(footer has component UselessComp)
we need nothing but a link to /Index
if now UselessComp has a state like UselessThing is String "thing" it could
be a link to /Index/thing
Why? because its the first thing in the URL after the Index/ - and its the
first thing the component would need and UselessComp gets it because its the
first component that needs sth.
if now SearchField also contains a String "Foo" it would then be:
/Index/Foo/thing
now we only have the problem that we dont know if wether Searchfield gets
Foo or thing (1st example)
the soluton would be to encode the component name itself and to give the
developer the chance to alter this name e.g: same as we do with mount for
pages, we could do this for Components
e.g:
Page: Index
has component: SearchfieldComp (mounted to LOOK)
has component: FooterComp (mounted to nothing as it never gets anything)
(footer has component UselessComp) (mounted to USELESS)
-> solutionlink: /Index/LOOK/Foo/USELESS/thing
this would be the key solution - if the wicket user needs nice URL he gets
the maximum possibility to alter the names if not, he gets ugly URLs like
before.
This means, if we also provide names to components (the ability) then we
clould also unify bookmarkable link as well as link as it wouldnt matter
what kind we have, we would only check if all components nested in that page
have names, if not -> ugly URL, if they have -> nice URL !
now, wouldnt this be a solution worth digging in???
Best Regards,
Korbinian
> -----Ursprüngliche Nachricht-----
> Von: Eelco Hillenius [mailto:eelco.hillenius@gmail.com]
> Gesendet: Mittwoch, 11. Oktober 2006 19:00
> An: wicket-dev@incubator.apache.org
> Betreff: Re: externalizing state by components
>
> On 10/11/06, Frank Bille <fr...@gmail.com> wrote:
> > But shouldn't the page be bookmarkable then? How else are
> you going to
> > make use of that externalized component? Except if I have got your
> > concept of "externalizing" wrong (= bookmarkable)
>
> No this externalizable thing only means that 'state' is being
> passed as part of the URL. So an URL like this
>
> http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:
>
> could be something like
>
> http://localhost:8081/tsp/web?wicket:interface=_wf_component:1
> :10:1:&wicket:state=dfskajkladsjf676sdfa
>
> where that state is an encoded set of parameters. That
> encoding could be overridden to make them look nice (but less
> efficient) on a component basis (ParameterUrlEncoder), so
> that it could look like
>
> http://someserver/foo/bar/books/Brave_New_World
>
> Where books,Brave_New_World is what is contributed by the
> component, and points to a bookmarkable page mounted at /bar/books.
>
> Also: please note that I'm still thinking about this. It
> would be more helpful to think with me how we could pull this
> off, then to try to find things why it couldn't work. IMO, if
> we can implement this, it would be a huge potential
> improvement in our scalability and bookmarkability options.
>
> Eelco
>
Re: externalizing state by components
Posted by Eelco Hillenius <ee...@gmail.com>.
On 10/11/06, Frank Bille <fr...@gmail.com> wrote:
> But shouldn't the page be bookmarkable then? How else are you going to
> make use of that externalized component? Except if I have got your
> concept of "externalizing" wrong (= bookmarkable)
No this externalizable thing only means that 'state' is being passed
as part of the URL. So an URL like this
http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:
could be something like
http://localhost:8081/tsp/web?wicket:interface=_wf_component:1:10:1:&wicket:state=dfskajkladsjf676sdfa
where that state is an encoded set of parameters. That encoding could
be overridden to make them look nice (but less efficient) on a
component basis (ParameterUrlEncoder), so that it could look like
http://someserver/foo/bar/books/Brave_New_World
Where books,Brave_New_World is what is contributed by the component,
and points to a bookmarkable page mounted at /bar/books.
Also: please note that I'm still thinking about this. It would be more
helpful to think with me how we could pull this off, then to try to
find things why it couldn't work. IMO, if we can implement this, it
would be a huge potential improvement in our scalability and
bookmarkability options.
Eelco
Re: externalizing state by components
Posted by Frank Bille <fr...@gmail.com>.
But shouldn't the page be bookmarkable then? How else are you going to
make use of that externalized component? Except if I have got your
concept of "externalizing" wrong (= bookmarkable)
Frank
On 10/11/06, Eelco Hillenius <ee...@gmail.com> wrote:
> On 10/11/06, Igor Vaynberg <ig...@gmail.com> wrote:
> > so what happens if you have a component that supports it and a component
> > that doesnt?
> >
> > you go to this bookmarkable url and only the component that supported
> param
> > externalization has its state restored, the other one starts new?
>
> No, it would work just like you can have stateless and normal
> components mixed now, and a page is not stateless unless everything
> nested in it is stateless. Components that are externalizable are not
> automatically stateless, though they typically could be. But as long
> as there are statefull components on the page, the parameters are put
> in the url etc, but the page is still internal.
>
> Eelco
>
Re: externalizing state by components
Posted by Eelco Hillenius <ee...@gmail.com>.
On 10/11/06, Igor Vaynberg <ig...@gmail.com> wrote:
> so what happens if you have a component that supports it and a component
> that doesnt?
>
> you go to this bookmarkable url and only the component that supported param
> externalization has its state restored, the other one starts new?
No, it would work just like you can have stateless and normal
components mixed now, and a page is not stateless unless everything
nested in it is stateless. Components that are externalizable are not
automatically stateless, though they typically could be. But as long
as there are statefull components on the page, the parameters are put
in the url etc, but the page is still internal.
Eelco
Re: externalizing state by components
Posted by Igor Vaynberg <ig...@gmail.com>.
so what happens if you have a component that supports it and a component
that doesnt?
you go to this bookmarkable url and only the component that supported param
externalization has its state restored, the other one starts new?
kinda dangerous if you ask me
-Igor
On 10/11/06, Eelco Hillenius <ee...@gmail.com> wrote:
>
> Triggered by that question earlier this week about how to externalize
> the urls of a pageable list, I thought a little bit about
> externalizing state by components.
>
> I think with Wicket 2.0, we got a bit closer to being able to do that,
> as we can traverse the whole hierarchy after creation.
> RequestCycle#urlFor (or any of the delegates) could for instance
> traverse all components, and look for an annotation like this:
>
> public class SomePagingComponent extends Blah {
>
> ...
> @UrlEncoded private transient int pageNbr = 1;
>
> }
>
> Which would work with to string by default, and additionally,
> components could implement an interface to customize this:
>
> public interface ParameterUrlEncoder {
>
> CharSequence encode(String propertyName);
>
> void decode(String propertyName, String encodedValue);
>
> }
>
> The mechanism (somewhere in urlFor calls) could take care of the
> proper naming/scoping of variables, and could compress (and later
> decompress) the total contributed part of the URL. The request
> resolving part of the request cycle handling, should then inject the
> state again.
>
> Maybe (probably) I'm overlooking something, but I think this is
> feasible and actually not that hard to achieve. I think it would be
> VERY nice to have this, not only for bookmarkability without having
> having to give up on component scoped programming model, but also for
> scalability, where you can decide to use stateless pages with
> components like this (which could in many cases be stateless too).
>
> The main problem we would have is what to do with URLs that exceed the
> max lenght (which btw does not seems to fixed on 255 as I always
> thought, though 255 is recommended as a safe - but maybe outdated -
> upper limit, but I have seen 2048 and higher mentioned as well). The
> obvious thing to do is - like .NET and JSF - convert all gets to
> POSTs, but that gets really messy to implement (though due to our
> redirecting for renderings, users shouldn't notice).
>
> WDYT, anyone wants to give this a go?
>
> Eelco
>