1. #1
    Ext User
    Join Date
    Oct 2010
    Posts
    4
    Vote Rating
    0
    steve.me@gmail.com is on a distinguished road

      0  

    Default NumberField Won't Edit

    NumberField Won't Edit


    My Price field edits after it is created. As soon as it is refreshed from server the celleditor does not open.

    Here is the main widget class:

    public class SimpleXmlGrid extends LayoutContainer {

    ListStore<BaseModelData> store;
    XmlLoadResultReader<ListLoadResult<BaseModelData>> reader;
    BaseListLoader<ListLoadResult<BaseModelData>> loader;
    RestfulProxy<String> proxy;
    RestModelType modelType;

    EditorGrid<BaseModelData> grid;

    protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FlowLayout(10));

    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig();
    column.setId("Id");
    column.setHeader("Id");
    column.setWidth(15);
    column.setHidden(true);
    columns.add(column);

    column = new ColumnConfig();
    column.setId("Name");
    column.setHeader("Name");
    column.setWidth(165);
    TextField<String> text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    columns.add(column);

    column = new ColumnConfig();
    column.setId("Price");
    column.setHeader("Price");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(70);
    column.setNumberFormat(NumberFormat.getCurrencyFormat());
    column.setEditor(new CellEditor(new NumberField()));
    columns.add(column);

    ColumnModel columnModel = new ColumnModel(columns);

    // defines the xml structure
    modelType = new RestModelType();
    modelType.setRoot("Widgets");
    modelType.setRecordName("Widget");
    modelType.addField("Id");
    modelType.setPrimaryKey("Id");
    modelType.addField("Name");
    modelType.addField("Price");

    // String path = GWT.getHostPageBaseURL() + "SampleServer/widget";
    String path = "/SampleServer/widget";

    // CREATING PROXY, READER, AND LOADER AS PER GXT
    proxy = new RestfulProxy<String>();
    reader = new XmlLoadResultReader<ListLoadResult<BaseModelData>>(
    modelType);
    loader = new BaseListLoader<ListLoadResult<BaseModelData>>(proxy,
    reader);

    store = new ListStore<BaseModelData>(loader);
    grid = new EditorGrid<BaseModelData>(store, columnModel);

    grid.setBorders(true);
    grid.setLoadMask(true);
    grid.getView().setEmptyText("Please hit the load button.");
    grid.setAutoExpandColumn("Name");

    grid.reconfigure(store, grid.getColumnModel());

    ContentPanel panel = new ContentPanel();
    panel.setFrame(true);
    panel.setCollapsible(true);
    panel.setAnimCollapse(false);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setHeading("DDS GXT Client Prototype");
    panel.setLayout(new FitLayout());
    panel.add(grid);
    panel.setSize(425, 320);

    // add buttons
    panel.addButton(new Button("Get From SampleServer",
    new SelectionListener<ButtonEvent>() {
    public void componentSelected(ButtonEvent ce) {
    loader.load();
    }
    }));

    panel.addButton(new Button("Create Record",
    new SelectionListener<ButtonEvent>() {

    public void componentSelected(ButtonEvent ce) {
    Widget widget = new Widget();
    //widget.setName("enter");
    grid.stopEditing();
    store.insert(widget, 0);
    grid.startEditing(store.indexOf(widget), 1);
    }
    }));

    panel.addButton(new Button("Reset",
    new SelectionListener<ButtonEvent>() {

    @Override
    public void componentSelected(ButtonEvent ce) {
    store.rejectChanges();
    }
    }));

    panel.addButton(new Button("Save",
    new SelectionListener<ButtonEvent>() {

    @Override
    public void componentSelected(ButtonEvent ce) {
    updateToServer();
    }
    }));

    add(panel);
    }...

    HERE IS THE BASEMODELDATA CLASS:

    package net.dds.proto.client;

    import com.extjs.gxt.ui.client.data.BaseModel;
    import com.extjs.gxt.ui.client.data.BaseModelData;

    public class Widget extends BaseModel {

    public Widget(){

    }
    public void setId(String id) {
    set("id", id);
    }
    public String getId() {
    return (String)get("id");
    }

    public void setName(String name) {
    set("name", name);
    }
    public String getName() {
    return (String)get("name");
    }

    public void setPrice(Double price) {
    set("price", price);
    }
    public Double getPrice() {
    return (Double)get("price");
    }

    }

    I just cannot see anything different from a clasic example. The XML transferred seems OK.

    Thanks...

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    I dont understand your problem. I also dont see where you are doing a serverside call. Can you please post a fully working testcase that implements EntryPoint and shows your problem? Can you also tell us which GXT and GWT version you are using?

  3. #3
    Ext User
    Join Date
    Oct 2010
    Posts
    4
    Vote Rating
    0
    steve.me@gmail.com is on a distinguished road

      0  

    Default


    Thanks for the quick reply. I am using GWT 2.0.4 GXT 2.2.0

    The rest of the code:


    package net.dds.proto.client;

    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;

    /**
    * Entry point classes define <code>onModuleLoad()</code>.
    */
    public class GxtRestfulClient implements EntryPoint {

    @Override
    public void onModuleLoad() {
    SimpleXmlGrid xmlGrid = new SimpleXmlGrid();
    RootPanel.get().add(xmlGrid);
    //xmlGrid.eventInit();
    }
    }

    package net.dds.proto.client;

    import com.extjs.gxt.ui.client.data.ModelType;

    public class RestModelType extends ModelType {

    private String primaryKey;

    public void setPrimaryKey(String primaryKey) {
    this.primaryKey = primaryKey;
    }

    public String getPrimaryKey() {
    return primaryKey;
    }

    }

    package net.dds.proto.client;

    import java.util.Map;
    import java.util.Set;

    import com.extjs.gxt.ui.client.data.DataProxy;
    import com.extjs.gxt.ui.client.data.DataReader;
    import com.extjs.gxt.ui.client.data.ModelData;
    import com.extjs.gxt.ui.client.data.ModelType;
    import com.extjs.gxt.ui.client.store.Record;
    import com.google.gwt.http.client.Request;
    import com.google.gwt.http.client.RequestBuilder;
    import com.google.gwt.http.client.RequestCallback;
    import com.google.gwt.http.client.Response;
    import com.google.gwt.user.client.rpc.AsyncCallback;

    public class RestfulProxy<D> implements DataProxy<D> {

    public static class Params {
    public String path;

    public Params(String path){
    this.path = path;
    }
    }

    public void load(final DataReader<D> reader, final Object loadConfig,
    final AsyncCallback<D> callback) {

    try {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
    "/SampleServer/widget");

    builder.sendRequest(null, new RequestCallback() {
    public void onError(Request request, Throwable exception) {
    callback.onFailure(exception);
    }

    @SuppressWarnings("unchecked")
    public void onResponseReceived(Request request,
    Response response) {
    if (response.getStatusCode() != Response.SC_OK) {
    callback.onFailure(new RuntimeException(
    "HttpProxy: Invalid status code "
    + response.getStatusCode()));
    return;
    }
    String text = response.getText();
    try {
    D data = null;
    if (reader != null) {
    data = reader.read(loadConfig, text);
    } else {
    data = (D) text;
    }
    callback.onSuccess(data);
    } catch (Exception e) {
    e.printStackTrace();
    callback.onFailure(e);
    }
    }
    });
    } catch (Exception e) {
    callback.onFailure(e);
    }

    }

    public void put(String representaion, RestfulProxy.Params params, final AsyncCallback<D> callback) {

    try {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT,
    params.path);

    builder.setHeader("ACCEPT", "application/xml");
    builder.setHeader("CONTENT-TYPE", "text/xml");

    builder.sendRequest(representaion, new RequestCallback() {

    public void onError(Request request, Throwable exception) {
    callback.onFailure(exception);
    }

    @SuppressWarnings("unchecked")
    public void onResponseReceived(Request request,
    Response response) {
    if (response.getStatusCode() == Response.SC_ACCEPTED) {
    callback.onSuccess((D) response.getText());
    }else {
    callback.onFailure(new RuntimeException(
    "HTTP: Invalid status code "
    + response.getStatusCode()));
    }
    }
    });
    } catch (Exception e) {
    callback.onFailure(e);
    }
    }

    public String createXML(Record record, ModelType modelType) {

    StringBuilder sb = new StringBuilder();

    String recordName = modelType.getRecordName();
    Map<String, Object> changes = record.getChanges();
    ModelData md = record.getModel();
    //Map<String, Object> changes = md.getProperties();

    sb.append('<' + recordName + '>');
    Set<String> keys = changes.keySet();
    for (String key : keys) {
    sb.append("<" + key + ">");
    sb.append(md.get(key).toString());
    sb.append("</" + key + ">");
    }
    sb.append("</" + recordName + ">");

    return sb.toString();
    }
    }

    Here is the XML response to a GET (all):
    <Widgets><Widget><Id>1</Id><Name>Burgers</Name><Price>44.0</Price></Widget><Widget><Id>2</Id><Name>Beer</Name><Price>82.0</Price></Widget><Widget><Id>3</Id><Name>Buns</Name><Price>8.0</Price></Widget></Widgets>

    Thanks again...

  4. #4
    Ext User
    Join Date
    Oct 2010
    Posts
    4
    Vote Rating
    0
    steve.me@gmail.com is on a distinguished road

      0  

    Default


    After I retrieve all record from the server the NumberField editor does not become active when I click on it. It is active during create and whenit updates the server, not after getting from server.

Similar Threads

  1. edit values in Texfield / NumberField bbar
    By Paul.l in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 3 Dec 2008, 4:24 AM
  2. EditorGrid - Pressing alphabet on NumberField starts edit
    By mystix in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 28 Feb 2007, 9:29 AM

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi