Hey,
2010/9/28 但浩亮 <[email protected]>:
> 1. setTarget(TargetNewWindow) has no effect if the anchor is set by
> setRefInternalPath(). The link is still opened in the same window.
Good point. I fixed this in latest git!
> 2. with server configuration option tracking=Auto and
> reload-is-new-session=false, the application redirects its path from
> the url set by setRef() to the root ended with '#'. In other words,
> the anchor set by setRef() fails in navigating to its goal with such
> server settings.
>
> The following is demo code for bug #2( the entry is "/here", and the
> goal is "/here/goThere" ):
>
> #include <Wt/WAnchor>
> #include <Wt/WApplication>
> #include <Wt/WServer>
> using namespace Wt;
>
> struct MyApplication : WApplication {
> MyApplication( const WEnvironment& env ) : WApplication(env) {
> WAnchor *anchor = new WAnchor( root() );
> anchor->setText( "goThere" );
> anchor->setRef( "here/goThere" ); // "here#/goThere" is OK!
> }
> };
>
> WApplication *createApplication( const WEnvironment& env ) { return
> new MyApplication(env); }
>
> int main( int argc, char **argv ) {
> WServer server( argv[0], "configuration.xml" ); // <tracking> Auto
> and <reload-is-new-session> false
> server.setServerConfiguration( argc, argv, WTHTTP_CONFIGURATION );
> server.addEntryPoint( Application, createApplication, "here" );
> if( server.start() ) {
> WServer::waitForShutdown();
> server.stop();
> }
> return 0;
> }
>
> Clicking on the anchor "/here/goThere" will lead to "/here/goThere",
> and finally "/here#".
I have fixed this in latest git: now /here/goThere will end up in
/here#/goThere (this is the behavior that is expected).
I also discovered a caveat with latest git (and thus, the next
release): we now handle the window unload event which kills the
session. If you are putting an anchor to the same session which
requires a page refresh then you will kill your own session! You can
prevent this by specializing the unload() method of WApplication and
implement empty:
virtual void unload() { }
> The workaround is add a '#' in the url, but I don't like it because
> the url "/here/goThere" is prettier than "/here#/goThere".
While it may be prettier, it is not compatible with an AJAX
application: AJAX application can only benefit from AJAX while staying
in the same page. Since wt supports both plain HTML and AJAX sessions,
it will interpret the URL as the same but convert to a canonical URL
which is the "/here#/goThere" form for an AJAX session.
> If the latter, I think some explainations should be added in the witty
> document.
This is documented (I believe to a great extent but it may require
some more elaboration) with respect to the internal path API in
WApplication:
http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WApplication.html#2c1a10aadc0d7ed877b5715b42ca4911
Regards,
koen
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest