Hello,
(Using Smartgwt Power, snapshot of 13 december 2010)
I have a custom DataSource that connects to Twitter (called TwitterDataSource). Before it can be used, I need to be sure the user has authed using the oAuth mechanism, for which I have separate authentication servlet (which does the redirect-thingy of oAuth). This has to happen only once.
Once the user is authed, I want to proceed as usual, and update twitter statuses using my custom.
Currently, my add() operation of TwitterDataSource checks whether the user has authed on Twitter (ie. there is an authentication token stored somewhere), and if not, returns an error:
twitter.ds.xml
So from a DynamicForm I do this:
But somehow the code in the callback is never called. I just read another thread that says this was the way to go? What am I missing?
(Using Smartgwt Power, snapshot of 13 december 2010)
I have a custom DataSource that connects to Twitter (called TwitterDataSource). Before it can be used, I need to be sure the user has authed using the oAuth mechanism, for which I have separate authentication servlet (which does the redirect-thingy of oAuth). This has to happen only once.
Once the user is authed, I want to proceed as usual, and update twitter statuses using my custom.
Currently, my add() operation of TwitterDataSource checks whether the user has authed on Twitter (ie. there is an authentication token stored somewhere), and if not, returns an error:
Code:
public class TwitterDataSource extends BasicDataSource { @Override public DSResponse executeAdd(DSRequest req) throws Exception { ... if(notAuthedOnTwitter()){ DSResponse res = new DSResponse(); res.addError("tweet","NOT_AUTHENTICATED_ON_TWITTER"); return res; } } }
Code:
<?xml version="1.0" encoding="UTF-8"?> <DataSource ID="twitter" serverConstructor="nl.mypackage.server.customdatasources.TwitterDataSource" > <fields> <field name="twitter_username" type="text" length="50" primaryKey="true" /> <field name="api_key" type="text" length="255" /> <field name="tweet" type="text" length="140" /> </fields> </DataSource>
Code:
form.setDataSource(twDataSource); TextItem msg = new TextItem("tweet", "tweet"); IButton b = new IButton("Tweet"); DSRequest req = new DSRequest(); req.setWillHandleError(true); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { form.saveData(new DSCallback() { public void execute(DSResponse response, Object rawData, DSRequest request) { Map errors = response.getErrors(); if (errors.get("tweet") != null && errors.get("tweet").equals( "NOT_AUTHENTICATED_WITH_TWITTER")) { //call my authentication servlet using RPC, but THIS IS NEVER CALLED ... } } }, req); } });
Comment