It's very hard to find questions about GWTP (GWT Platform).
Ok, Here is my Story. I am using GWTP & eclipse to create the
Presenter-View structure automatically.
Example, I created a TestPresenter in eclipse, & it created 3 files:
TestPresenter.java, TestView.java, TestView.xml
In TestView.xml, i have:
<g:RadioButton ui:field="firstRadioButton" value="false" text="1st" />
<g:RadioButton ui:field="secondRadioButton" value="false" text="2nd" />
<g:RadioButton ui:field="bothRadioButton" value="true" text="Both" />
Now I want to set the GroupName automatically for each TestView, so in
TestView.java
public class TestView extends ViewImpl implements
TestPresenter.MyView {
private final Widget widget;
@UiField RadioButton firstRadioButton;
@UiField RadioButton secondRadioButton;
@UiField RadioButton bothRadioButton;
private String groupName;
@UiFactory
RadioButton makeRadioButton() {
return new RadioButton(groupName);
}
public interface Binder extends UiBinder<Widget, TestView> {
}
@Inject
public TestView(final Binder binder) {
widget = binder.createAndBindUi(this);
}
@Override
public Widget asWidget() {
return widget;
}
public RadioButton getFirstRadioButton() {
return firstRadioButton;
}
public RadioButton getSecondRadioButton() {
return secondRadioButton;
}
public RadioButton getBothRadioButton() {
return bothRadioButton;
}
}
In TestPresenter.java,
public class TestPresenter extends
PresenterWidget<TestPresenter.MyView> {
public interface MyView extends View {
public RadioButton getFirstRadioButton();
public RadioButton getSecondRadioButton();
public RadioButton getBothRadioButton();
}
}
Ok, finally I want to use many TestPresenter (by using setInLot) in
MainPresenter.java
So, in MainPresenter.java, I have:
public static final Object SLOT1=new Object();
public static final Object SLOT2=new Object();
public static final Object SLOT3=new Object();
public static final Object SLOT4=new Object();
//...... more lot
@Inject TestPresenter testPresenter1;
@Inject TestPresenter testPresenter2;
@Inject TestPresenter testPresenter3;
@Inject TestPresenter testPresenter4;
//.. more test presenter
in MainView.java, i have setInSlot
@UiField HTMLPanel mainHtmlPanel;
@Override
public void setInSlot(Object slot, Widget content){
if(slot==TestPresenter.SLOT1){
mainHtmlPanel.clear();
if(content!=null){
mainHtmlPanel.add(content);
}
}
else if(slot==TestPresenter.SLOT2){
mainHtmlPanel.clear();
if(content!=null){
mainHtmlPanel.add(content);
}
}
//... more else if here
}
Now, if i just do like that then I can not pass the groupName separately
for each TestPresenter & that is not good. So I want to pass the groupName
string for each TestPresenter so that each will have their own groupName.
SOmething like this
@Inject TestPresenter testPresenter1 ("group1");
@Inject TestPresenter testPresenter2 ("group2");
@Inject TestPresenter testPresenter3 ("group3");
@Inject TestPresenter testPresenter4 ("group4");
...
but I don't know how to it properly, so please tell me how to it properly
in GWTP?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.