How can a Presenter return a WidgetDisplay?

7 views
Skip to first unread message

marco.sbodio

unread,
Sep 30, 2010, 10:16:36 AM9/30/10
to GWT Presenter
Hello,

I am new to this group, and I have a question on gwt-presenter, which
is the subject of this post. Here is a short example to explain my
question.

Let's assume that I have the following:

public interface TopicPresenter extends Presenter {

public interface TopicDisplay extends WidgetDisplay {
public HasValue<String> getTopic();
public void setTopic(String text);
}

public void showTopic(Topic topic);

}

and also:

public class TopicPresenterImpl
extends WidgetPresenter<TopicDisplay>
implements TopicPresenter {

// methods omitted for brevity

}

and

public class TopicDisplayImpl implements TopicDisplay {

// methods omitted for brevity

}

Topic is of course a simple bean class.

Let's assume that somewhere in my code I have the following
initializations:

TopicDisplay topicDisplay = new TopicDisplayImpl();
TopicPresenter topicPresenter = new TopicPresenterImpl(topicDisplay,
eventBus);

(I know I can use GIN to make this better, but it's not the point
here)

Now, here comes the question: if I do

topicPresenter.getDisplay();

I get a net.customware.gwt.presenter.client.Display object on which I
cannot call asWidget(), that is what I need.

Since TopicPresenterImpl is extending WidgetPresenter, I would like
that getDisplay() to return me a WidgetDisplay, that is in fact what
TopicDisplay extends. Of course this is happening because
TopicPresenter is extending Presenter, and I cannot find a way out of
it..

My first idea would be to rename the WidgetPresenter abstract class as
AbstractWidgetPresenter, and add a WidgetPresenter interface extending
Presenter, and having a method

WidgetDisplay getDisplay();

what do you think? am I totally wrong, and should I follow a different
approach?
any comment/help is appreciated

Thank you in advance.

Cheers,
marco

p.s. I'm using gwt-presenter-1.1.1
Reply all
Reply to author
Forward
0 new messages