0
제발 도와주세요. 필자는 데이터베이스에서 채우는 UiBinder가있는 CellBrowser를 만들었습니다. 문제는 InitWidget 메서드를 사용하여 표시 할 수 없다는 것입니다. 그러나 RootPanel에 직접 연결하면 (명령을 사용하면 : RootPanel.get(). add (cellBrowser);), 표시되지만 컴포지션에 연결된 다른 copoeents를 통해 (실제 엉망이됩니다 : /). HTMLPanel에 넣었지만 작동하지 않습니다.GWT : CellBrowser가 복합체로 표시되지 않습니다.
어떻게하면 합성에 첨부하여 다른 위젯과 함께 표시 할 수 있습니까? (나는 다른 패널을 시도했지만 작동하지 않았다 : /). 여기
내 코드입니다 :UiBinder 파일 :
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:c='urn:import:com.google.gwt.user.cellview.client'>
<ui:style>
#errors {
color: red;
}
#success {
color: green;
}
.arrondie {
border: 1px solid black;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border-radius: 7px;
background-color: #FFFFCC;
}
</ui:style>
<g:HorizontalPanel>
<g:HTMLPanel>
<table align="center" id="arrondie">
<tr>
<td colspan="3" align="center">
<div id="errors" align="center"></div>
<br />
<div id="success" align="center"></div>
</td>
</tr>
<tr>
<td>
<g:Label text="Unit's family:" />
</td>
<td colspan="2">
<g:TextBox width="15em" ui:field="familyName" />
</td>
</tr>
<tr>
<td>
<g:Label text="Unit:" />
</td>
<td>
<g:TextBox width="15em" ui:field="unitName" />
</td>
<td>
<g:Button ui:field="addUnit" text="Add unit" />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<g:Button ui:field="submit" text="Submit" />
</td>
</tr>
</table>
</g:HTMLPanel>
<g:HTMLPanel>
<c:CellBrowser defaultColumnWidth='300' ui:field='cellBrowser' />
</g:HTMLPanel>
</g:HorizontalPanel>
</ui:UiBinder>
뷰 :
public class UniteViewImpl extends Composite implements UniteView {
private Presenter presenter;
private static UniteViewImplUiBinder uiBinder = GWT.create(UniteViewImplUiBinder.class);
private ListDataProvider<FamilleUniteProxy> dataProvider;
interface UniteViewImplUiBinder extends UiBinder<Widget, UniteViewImpl> {
}
@SuppressWarnings("deprecation")
public UniteViewImpl() {
dataProvider = new ListDataProvider<FamilleUniteProxy>(
new ArrayList<FamilleUniteProxy>());
TreeViewModel model = new CustomTreeModel(dataProvider);
cellBrowser = new CellBrowser(model, null);
cellBrowser.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
cellBrowser.setHeight("200");
cellBrowser.setWidth("630");
RootPanel.get().add(cellBrowser); // If I delete this line, the cellBrowser is not displayed
initWidget(uiBinder.createAndBindUi(this));
}
@UiField
TextBox familyName;
@UiField
TextBox unitName;
@UiField
Button addUnit;
@UiField
Button submit;
@UiField(provided = true)
CellBrowser cellBrowser;
public UniteViewImpl(String firstName) {
initWidget(uiBinder.createAndBindUi(this));
}
@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
}
public void updateProvider(List<FamilleUniteProxy> familles) {
dataProvider.setList(familles);
dataProvider.refresh();
}
@UiFactory
public CellBrowser getCellBrowser() {
return cellBrowser;
}
}
TreeViewModel 클래스 :
class CustomTreeModel implements TreeViewModel {
private ListDataProvider<FamilleUniteProxy> dataProvider ;
public CustomTreeModel(ListDataProvider<FamilleUniteProxy> dataProvider) {
this.dataProvider = dataProvider;
}
public <T> NodeInfo<?> getNodeInfo(T value) {
if (value == null) {
Cell<FamilleUniteProxy> cell = new AbstractCell<FamilleUniteProxy>() {
@Override
public void render(Context context, FamilleUniteProxy value,
SafeHtmlBuilder sb) {
sb.appendEscaped(value.getIntituleFamilleUnite());
}
};
return new DefaultNodeInfo<FamilleUniteProxy>(dataProvider, cell);
} else if (value instanceof FamilleUniteProxy) {
ListDataProvider<UniteProxy> dataProvider = new ListDataProvider<UniteProxy>(
((FamilleUniteProxy) value).getUnites());
Cell<UniteProxy> cell = new AbstractCell<UniteProxy>() {
@Override
public void render(Context context, UniteProxy value,
SafeHtmlBuilder sb) {
if (value != null) {
sb.appendEscaped(value.getIntituleUnite());
}
}
};
return new DefaultNodeInfo<UniteProxy>(dataProvider, cell);
}
return null;
}
public boolean isLeaf(Object value) {
if (value instanceof UniteProxy) {
return true;
}
return false;
}
}
매우 분명하고 감사드립니다.