Sunday, 15 May 2011

gwt - GWTP RootPresenter from "Getting started section" -



gwt - GWTP RootPresenter from "Getting started section" -

i'm doing getting started in https://code.google.com/p/gwt-platform/wiki/gettingstarted#embedding_a_gwtp_app_in_a_webpage

some why when add together code rootpresenter:

`

public class myrootpresenter extends rootpresenter { public static final class myrootview extends rootview { @override public void setinslot(object slot, iswidget widget) { rootpanel.get("content").add(widget); } } @inject public myrootpresenter( eventbus eventbus, myrootview myrootview ) { super( eventbus, myrootview ); } }

`

it display app, when have <.. id="content"></ ..> correct. when add together element, , go 1 page another, not remove, old presenters html.

my gininjector:

`

@ginmodules({ mymodule.class }) public interface myginjector extends ginjector { placemanager getplacemanager(); eventbus geteventbus(); asyncprovider<mainpagepresenter> getmainpagepresenter(); asyncprovider<nextpagepresenter> getnextpagepresenter(); }

`

mymodule: `

public class mymodule extends abstractpresentermodule { @override protected void configure() { // install(new defaultmodule(myplacemanager.class)); install(new commonginmodule()); bind(eventbus.class).to(simpleeventbus.class).in(singleton.class); bind(tokenformatter.class).to(parametertokenformatter.class).in(singleton.class); bind(rootpresenter.class).to(myrootpresenter.class).aseagersingleton(); bind(placemanager.class).to(myplacemanager.class).in(singleton.class); bind(googleanalytics.class).to(googleanalyticsimpl.class).in(singleton.class); // presenters bindpresenter(mainpagepresenter.class, mainpagepresenter.myview.class, mainpageview.class, mainpagepresenter.myproxy.class ); bindpresenter(nextpagepresenter.class, nextpagepresenter.mynextview.class, nextpageview.class, nextpagepresenter.mynextproxy.class); } }

`

mypresenter(the other 1 much this): `

public class mainpagepresenter extends presenter<mainpagepresenter.myview, mainpagepresenter.myproxy> { public interface myview extends view { } @proxycodesplit @nametoken("main") public interface myproxy extends proxyplace<mainpagepresenter> {} @inject public mainpagepresenter(eventbus eventbus, myview view, myproxy proxy) { super(eventbus, view, proxy); } @override protected void revealinparent() { revealrootcontentevent.fire( this, ); } }

`

and view:

public class mainpageview extends viewimpl implements mainpagepresenter.myview { private static string html = "<h1>web application starter project</h1>\n" + "<table align=\"center\">\n" + " <tr>\n" + " <td colspan=\"2\" style=\"font-weight:bold;\">please come in name:</td>\n" + " </tr>\n" + " <tr>\n" + " <td id=\"namefieldcontainer\"></td>\n" + " <td id=\"sendbuttoncontainer\"></td>\n" + " </tr>\n" + " <tr>\n" + " <td colspan=\"2\" style=\"color:red;\" id=\"errorlabelcontainer\"></td>\n" + " </tr>\n" + "</table>\n"; htmlpanel panel = new htmlpanel(html); @inject public mainpageview(final placemanager myplacemanager) { final button sendbutton = new button("send"); final textbox namefield = new textbox(); namefield.settext("gwt user"); final label errorlabel = new label(); // can add together style names widgets sendbutton.addstylename("sendbutton"); sendbutton.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { placerequest request = new placerequest("next"); myplacemanager.revealplace(request); } }); // add together namefield , sendbutton rootpanel // utilize rootpanel.get() entire body element panel.add(namefield, "namefieldcontainer"); panel.add(sendbutton, "sendbuttoncontainer"); panel.add(errorlabel, "errorlabelcontainer"); } @override public widget aswidget() { homecoming panel; } }

reading getting started page, should quite straight forward. how, doesn't work right.

gwt gwtp

No comments:

Post a Comment