View Full Version : ComboBox with Multi Selection - Dont compile
vinicius.rabelo
5 Aug 2009, 11:11 AM
When I try to compile my app, I receive errors in lines that use JNSI (in the class XComboBox)...
The error is:
[ERROR] Errors in file:/my workspace path/my app/client/XComboBox.java
[ERROR] Line 101: Unresolvable native reference to field 'assetHeight' in type 'my app.client.util.XComboBox'
[ERROR] Line 105: Unresolvable native reference to field 'eventPreview' in type 'my app.client.XComboBox'
[ERROR] Line 109: Unresolvable native reference to field 'footer' in type 'my app.client.XComboBox'
[ERROR] Line 113: Unresolvable native reference to field 'hiddenInput' in type 'my app.client.XComboBox'
[ERROR] Line 126: Unresolvable native reference to field 'storeListener' in type 'my app.client.XComboBox'
[ERROR] Line 200: Unresolvable native reference to field 'assetHeight' in type 'my app.client.XComboBox'
[ERROR] Line 204: Unresolvable native reference to field 'footer' in type 'my app.client.XComboBox'
[ERROR] Line 208: Unresolvable native reference to field 'initialized' in type 'my app.client.XComboBox'
[ERROR] Line 212: Unresolvable native reference to field 'list' in type 'my app.client.XComboBox'
[ERROR] Line 216: Unresolvable native reference to field 'mode' in type 'my app.client.XComboBox'
[ERROR] Line 220: Unresolvable native reference to field 'pageTb' in type 'my app.client.XComboBox'
How to resolve this error?
Thanks
Arno.Nyhm
7 Aug 2009, 6:50 AM
without your code its impossible to try to resolve it.
vinicius.rabelo
7 Aug 2009, 11:54 AM
Excuse me... The code is:
My EntryPoint
public class TesteGxt implements EntryPoint {
public void onModuleLoad() {
final Viewport viewport = new Viewport();
viewport.add(getFormPanel());
RootPanel.get().add(viewport);
GXT.hideLoadingPanel("loading");
}
private FormPanel formPanel;
private FormPanel getFormPanel() {
if (formPanel != null) {
return formPanel;
}
formPanel = new FormPanel();
formPanel.add(getSituacao());
return formPanel;
}
private XComboBox<ModelData> situacao;
private XComboBox<ModelData> getSituacao() {
if (situacao != null) {
return situacao;
}
situacao = new XComboBox<ModelData>();
situacao.setFieldLabel("Situação");
situacao.setDisplayField("name");
situacao.setStore(getListStoreSituacoes());
return situacao;
}
private ListStore<ModelData> listStoreSituacoes;
private ListStore<ModelData> getListStoreSituacoes() {
if (listStoreSituacoes != null) {
return listStoreSituacoes;
}
listStoreSituacoes = new ListStore<ModelData>();
listStoreSituacoes.add(new SituacaoBM(1, "Em edição"));
listStoreSituacoes.add(new SituacaoBM(2, "Em atendimento"));
listStoreSituacoes.add(new SituacaoBM(3, "Em aprovação"));
listStoreSituacoes.add(new SituacaoBM(4, "Em prestação de Contas"));
listStoreSituacoes.add(new SituacaoBM(5, "Concluida"));
listStoreSituacoes.add(new SituacaoBM(6, "Cancelada"));
return listStoreSituacoes;
}
}
class SituacaoBM extends BaseModel {
private static final long serialVersionUID = 1L;
public SituacaoBM(int id, String name) {
set("id", id);
set("name", name);
}
}
The XComboBox (http://www.extjs.com/forum/showthread.php?t=73726)
I only changed:
this.@com.extjs.gxt.samples.explorer.client.XComboBox
to
this.@br.com.testegxt.client.XComboBox
package br.com.testegxt.client.XComboBox;
import java.util.List;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.core.El;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.PagingLoader;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.StoreListener;
import com.extjs.gxt.ui.client.util.BaseEventPreview;
import com.extjs.gxt.ui.client.widget.CheckBoxListView;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.ListView;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ListModelPropertyEditor;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;
public class XComboBox<D extends ModelData> extends ComboBox<D> {
private String valueFieldSeparator = ";";
private String rawSeparator = ", ";
public XComboBox() {
messages = new ComboBoxMessages();
setView(new CheckBoxListView<D>());
setPropertyEditor(new ListModelPropertyEditor<D>());
monitorWindowResize = true;
windowResizeDelay = 0;
initComponent();
setTriggerAction(TriggerAction.ALL);
}
private void bindStore(ListStore<D> store, boolean initial) {
if (this.store != null && !initial) {
this.store.removeStoreListener(getStoreListener());
if (store == null) {
this.store = null;
if (getView() != null) {
getView().setStore(null);
}
}
}
if (store != null) {
this.store = store;
if (store.getLoader() == null) {
setMode("local");
}
if (getView() != null) {
getView().setStore(store);
}
store.addStoreListener(getStoreListener());
}
}
@Override
public void collapse() {
super.collapse();
String text = "";
for (D d : getSelection()) {
if (text.length() > 0) {
text += rawSeparator;
}
text += d.get(getDisplayField());
}
setRawValue(text);
updateHiddenValue();
}
private void createList(boolean remove, LayoutContainer list) {
RootPanel.get().add(list);
setInitialized(true);
if (getPagingToolBar() != null) {
setFooter(list.el().createChild(
"<div class='" + getListStyle() + "-ft'></div>"));
getPagingToolBar().setBorders(false);
getPagingToolBar().render(getFooter().dom);
setAssetHeight(getAssetHeight() + getFooter().getHeight());
}
if (remove) {
RootPanel.get().remove(list);
}
}
@Override
protected void doForce() {
return;
}
private native int getAssetHeight() /*-{
return this.@br.com.testegxt.client.XComboBox::assetHeight;
}-*/;
private native BaseEventPreview getEventPreview() /*-{
return this.@br.com.testegxt.client.XComboBox::eventPreview;
}-*/;
private native El getFooter() /*-{
return this.@br.com.testegxt.client.XComboBox::footer;
}-*/;
private native InputElement getHiddenInput() /*-{
return this.@br.com.testegxt.client.XComboBox::hiddenInput;
}-*/;
public String getRawSeparator() {
return rawSeparator;
}
@Override
public List<D> getSelection() {
return ((CheckBoxListView<D>) getView()).getChecked();
}
private native StoreListener<D> getStoreListener() /*-{
return this.@br.com.testegxt.client.XComboBox::storeListener;
}-*/;
@Override
public D getValue() {
return null;
}
public String getValueFieldSeparator() {
return valueFieldSeparator;
}
@SuppressWarnings("unchecked")
@Override
protected void initList() {
ListView<D> listView = getView();
if (listView == null) {
setView(new CheckBoxListView<D>());
}
String style = getListStyle();
listView.setStyleAttribute("overflowX", "hidden");
listView.setStyleName(style + "-inner");
listView.setStyleAttribute("padding", "0px");
listView.setSelectOnOver(true);
listView.setBorders(false);
listView.setStyleAttribute("backgroundColor", "white");
listView.setSelectStyle(getSelectedStyle());
listView.setLoadingText(getLoadingText());
if (getTemplate() == null) {
listView.setDisplayProperty(getDisplayField());
} else {
listView.setTemplate(getTemplate());
}
setAssetHeight(0);
LayoutContainer list = new LayoutContainer() {
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
getEventPreview().getIgnoreList().add(getElement());
}
};
list.setScrollMode(Scroll.NONE);
list.setShim(true);
list.setShadow(true);
list.setBorders(true);
list.setStyleName(style);
list.hide();
assert store != null : "ComboBox needs a store";
list.add(listView);
setList(list);
if (getPageSize() > 0) {
PagingToolBar pageTb = new PagingToolBar(getPageSize());
pageTb.bind((PagingLoader) store.getLoader());
setPagingToolBar(pageTb);
}
if (!isLazyRender()) {
createList(true, list);
}
bindStore(store, true);
};
private native void setAssetHeight(int assetHeight) /*-{
this.@br.com.testegxt.client.XComboBox::assetHeight = assetHeight;
}-*/;
private native void setFooter(El footer) /*-{
this.@br.com.testegxt.client.XComboBox::footer = footer;
}-*/;
private native void setInitialized(boolean initialized) /*-{
this.@br.com.testegxt.client.XComboBox::initialized = initialized;
}-*/;
private native void setList(LayoutContainer list)/*-{
this.@br.com.testegxt.client.XComboBox::list = list;
}-*/;
private native void setMode(String mode)/*-{
this.@br.com.testegxt.client.XComboBox::mode = mode;
}-*/;
private native void setPagingToolBar(PagingToolBar pageTb)/*-{
this.@br.com.testegxt.client.XComboBox::pageTb = pageTb;
}-*/;
public void setRawSeparator(String rawSeparator) {
this.rawSeparator = rawSeparator;
}
@Override
public void setSelection(List<D> selection) {
for (D d : selection) {
((CheckBoxListView<D>) getView()).setChecked(d, true);
}
super.setSelection(selection);
}
@Override
public void setValue(D value) {
return;
}
public void setValueFieldSeparator(String valueFieldSeparator) {
this.valueFieldSeparator = valueFieldSeparator;
}
private void updateHiddenValue() {
if (getHiddenInput() != null) {
String v = "";
for (D d : getSelection()) {
if (v.length() > 0) {
v += valueFieldSeparator;
}
v += d.get(getValueField());
}
getHiddenInput().setValue(v);
}
}
}
This is a JSNI issue. To access the private members you need to access them there, where they got defined.
vinicius.rabelo
7 Aug 2009, 12:29 PM
Then, in this case I only "can to access" this fields in the class
com.extjs.gxt.ui.client.widget.form.ComboBox? Is equal the control access on Java...
Consequently the widget XComboBox is not working?
Sure it will work.
Just change your code:
private native void setInitialized(boolean initialized) /*-{
this.@com.extjs.gxt.ui.client.form.ComboBox::initialized = initialized;
}-*/;
You need to access it there, where it got defined.
vinicius.rabelo
10 Aug 2009, 5:21 AM
Now it's working...
Alerting only to change to
com.extjs.gxt.ui.client.widget.form.ComboBox::initialized
and not to
com.extjs.gxt.ui.client.form.ComboBox::initialized
Thanks a lot
raj_s37
16 Jan 2012, 1:22 AM
It worked finely please let me know how to set the selected value in the combox
raj_s37
31 Jan 2012, 4:33 AM
Please let me know how to integrate XComboBox inside GridEditor.
I have used the CellEditor in which the preprocessor method returns model value,but in this case i need to return the list of model values.Its urgent.Please provide the feedback ASAP
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.