Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problems Migrating from 2.5 to 3.1 SmartGWT

    Be sure your post includes:

    1. SmartGWT 3.1, per the developer console, v8.3_2012-11-20/LGPL Development Only (built 2012-11-20)
    2. any browser
    5. if there is a JavaScript error, the stack trace logged in the Developer Console
    Code:
    09:23:43.640:INFO:Log:initialized
    09:23:43.949:WARN:Log:New Class ID: 'DataView' collides with ID of existing object with value 'function DataView() {
        [native code]
    }'.  Existing object will be replaced.
    This conflict would be avoided by disabling ISC Simple Names mode.  See documentation for further information.
    09:24:22.738:INFO:Log:isc.Page is loaded
    I had a perfectly fine working application with SmartGWT 2.4 and SmartGWT 2.5.
    Then I went to update the code to SmartGWT 3.1, the latest using a maven POM build so i don't know the exact version of 3.1, but I will get it and add it here.

    However, I am now constantly getting these errors all over the place, and from what i can figure out it has a lot to do with the selectItem and forms, or forms in general.

    I have built multiple older SmartGWt 2.4 apps before, and never had an issue, and I may have to go back to that version to avoid these issues. And I have always used the SmartGWT Showcase to show me what to do with code.

    Is there any knowledge or advice on how to fix these multiple null issues with JavaScript.

    Thanks!

    Code:
    09:36:54.102 [ERROR] [Troop22Software] Uncaught exception escaped
    
    com.google.gwt.core.client.JavaScriptException: (TypeError) @com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)([JavaScript object(4265), JavaScript object(4264), JavaScript object(4614)]): _13 is null
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
        at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:299)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
        at com.google.gwt.user.client.Window.alert(Window.java)
        at com.smartgwt.client.SmartGwtEntryPoint$1.onUncaughtException(SmartGwtEntryPoint.java:303)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:244)
        at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Thread.java:662)
    Code:
    package com.opensource.troop22.client.datasources;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.core.client.JavaScriptObject;
    import com.google.gwt.user.client.rpc.AsyncCallback;
    import com.opensource.troop22.client.services.UserService;
    import com.opensource.troop22.client.services.UserServiceAsync;
    import com.opensource.troop22.client.utils.datasource.GwtRpcDataSource;
    import com.opensource.troop22.shared.Constants;
    import com.opensource.troop22.shared.dto.RoleDTO;
    import com.opensource.troop22.shared.dto.UserDTO;
    import com.opensource.troop22.shared.dto.UserRoleDTO;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.fields.DataSourceBooleanField;
    import com.smartgwt.client.data.fields.DataSourceDateField;
    import com.smartgwt.client.data.fields.DataSourceEnumField;
    import com.smartgwt.client.data.fields.DataSourceIntegerField;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    import com.smartgwt.client.rpc.RPCResponse;
    import com.smartgwt.client.util.JSOHelper;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    
    public class UserDS extends GwtRpcDataSource
    {
    
        private static UserDS instance = null;
    
        private final UserServiceAsync userService = GWT.create(UserService.class);
    
        public static UserDS getInstance()
        {
            if (instance == null)
            {
                instance = new UserDS();
            }
            return instance;
        }
    
        DataSourceIntegerField userIdField;
        DataSourceBooleanField userActiveField;
        DataSourceTextField usernameField;
        DataSourceTextField passwordField;
    
        DataSourceTextField userPrefixField;
        DataSourceTextField userFirstNameField;
        DataSourceTextField userMiddleNameField;
        DataSourceTextField userLastNameField;
        DataSourceTextField userSuffixField;
    
        DataSourceTextField userFullNameField;
    
        DataSourceTextField address1Field;
        DataSourceTextField address2Field;
        DataSourceTextField cityField;
        DataSourceTextField stateField;
        DataSourceTextField zipField;
    
        DataSourceTextField userHomeEmailField;
        DataSourceTextField userWorkEmailField;
    
        DataSourceTextField userHomePhoneField;
        DataSourceTextField userWorkPhoneField;
        DataSourceTextField userMobilPhoneField;
    
        DataSourceTextField userQuestion1Field;
        DataSourceTextField userAnswer1Field;
        DataSourceTextField userQuestion2Field;
        DataSourceTextField userAnswer2Field;
    
        DataSourceDateField userBirthdateField;
        DataSourceDateField userJoinedField;
        DataSourceDateField userLeftField;
    
        DataSourceEnumField userRolesField;
    
        public UserDS()
        {
            super();
            setID("UsersGwtRpcDataSource");
    
            userIdField = new DataSourceIntegerField(Constants.USER_ID, Constants.TITLE_USER_ID);
            userIdField.setPrimaryKey(true);
            userIdField.setCanEdit(false);
            userIdField.setHidden(true);
    
            userActiveField = new DataSourceBooleanField(Constants.USER_ACTIVE, Constants.TITLE_USER_ACTIVE);
            usernameField = new DataSourceTextField(Constants.USER_USERNAME, Constants.TITLE_USER_USERNAME);
            passwordField = new DataSourceTextField(Constants.USER_PASSWORD, Constants.TITLE_USER_PASSWORD);
    
            userPrefixField = new DataSourceTextField(Constants.USER_PREFIX, Constants.TITLE_USER_PREFIX);
            userFirstNameField = new DataSourceTextField(Constants.USER_FIRST_NAME, Constants.TITLE_USER_FIRST_NAME);
            userMiddleNameField = new DataSourceTextField(Constants.USER_MIDDLE_NAME, Constants.TITLE_USER_MIDDLE_NAME);
            userLastNameField = new DataSourceTextField(Constants.USER_LAST_NAME, Constants.TITLE_USER_LAST_NAME);
            userSuffixField = new DataSourceTextField(Constants.USER_SUFFIX, Constants.TITLE_USER_SUFFIX);
    
            userFullNameField = new DataSourceTextField(Constants.USER_FULL_NAME, Constants.TITLE_USER_FULL_NAME);
    
            address1Field = new DataSourceTextField(Constants.USER_ADDRESS1, Constants.TITLE_USER_ADDRESS1);
            address2Field = new DataSourceTextField(Constants.USER_ADDRESS2, Constants.TITLE_USER_ADDRESS2);
            cityField = new DataSourceTextField(Constants.USER_CITY, Constants.TITLE_USER_CITY);
            stateField = new DataSourceTextField(Constants.USER_STATE, Constants.TITLE_USER_STATE);
            zipField = new DataSourceTextField(Constants.USER_ZIP, Constants.TITLE_USER_ZIP);
    
            userHomeEmailField = new DataSourceTextField(Constants.USER_HOME_EMAIL, Constants.TITLE_USER_HOME_EMAIL);
            userWorkEmailField = new DataSourceTextField(Constants.USER_WORK_EMAIL, Constants.TITLE_USER_WORK_EMAIL);
    
            userHomePhoneField = new DataSourceTextField(Constants.USER_HOME_PHONE, Constants.TITLE_USER_HOME_PHONE);
            userWorkPhoneField = new DataSourceTextField(Constants.USER_WORK_PHONE, Constants.TITLE_USER_WORK_PHONE);
            userMobilPhoneField = new DataSourceTextField(Constants.USER_MOBIL_PHONE, Constants.TITLE_USER_MOBIL_PHONE);
    
            userQuestion1Field =
                new DataSourceTextField(Constants.USER_SECURITY_QUESTION_1, Constants.TITLE_USER_SECURITY_QUESTION_1, 200);
            userAnswer1Field =
                new DataSourceTextField(Constants.USER_SECURITY_ANSWER_1, Constants.TITLE_USER_SECURITY_ANSWER_1, 200);
    
            userQuestion2Field =
                new DataSourceTextField(Constants.USER_SECURITY_QUESTION_2, Constants.TITLE_USER_SECURITY_QUESTION_2, 200);
            userAnswer2Field =
                new DataSourceTextField(Constants.USER_SECURITY_ANSWER_2, Constants.TITLE_USER_SECURITY_ANSWER_2, 200);
    
            userBirthdateField = new DataSourceDateField(Constants.USER_BIRTHDATE, Constants.TITLE_USER_BIRTHDATE, 200);
            userJoinedField = new DataSourceDateField(Constants.USER_JOINED_DATE, Constants.TITLE_USER_JOINED_DATE, 200);
            userLeftField = new DataSourceDateField(Constants.USER_LEFT_DATE, Constants.TITLE_USER_LEFT_DATE, 200);
    
            userRolesField = new DataSourceEnumField(Constants.USER_ROLES, Constants.TITLE_USER_ROLES);
    
            setFields(userIdField, userFullNameField, userActiveField, usernameField, passwordField, userPrefixField,
                userFirstNameField, userMiddleNameField, userLastNameField, userSuffixField, address1Field, address2Field,
                cityField, stateField, zipField, userHomeEmailField, userWorkEmailField, userHomePhoneField,
                userWorkPhoneField, userMobilPhoneField, userQuestion1Field, userAnswer1Field, userQuestion2Field,
                userAnswer2Field, userBirthdateField, userJoinedField, userLeftField, userRolesField);
        }
    
        // *************************************************************************************
        // *************************************************************************************
    
        @Override
        protected void executeAdd(final String requestId, final DSRequest request, final DSResponse response)
        {
            // Retrieve record which should be added.
            JavaScriptObject data = request.getData();
            ListGridRecord rec = new ListGridRecord(data);
            UserDTO testRec = new UserDTO();
            copyValues(rec, testRec);
            userService.add(testRec, new AsyncCallback<UserDTO>()
            {
                public void onFailure(Throwable caught)
                {
                    response.setStatus(RPCResponse.STATUS_FAILURE);
                    processResponse(requestId, response);
                    SC.say("Add Member", "New member cannot be added!");
                }
    
                public void onSuccess(UserDTO result)
                {
                    ListGridRecord[] list = new ListGridRecord[1];
                    ListGridRecord newRec = new ListGridRecord();
                    copyValues(result, newRec);
                    list[0] = newRec;
                    response.setData(list);
                    processResponse(requestId, response);
                    SC.say("Add Member", "New memberhas been successfully added!");
                }
            });
        }
    
        @Override
        protected void executeRemove(final String requestId, final DSRequest request, final DSResponse response)
        {
            // Retrieve record which should be updated
            JavaScriptObject data = request.getData();
            final ListGridRecord rec = new ListGridRecord(data);
            UserDTO testRec = new UserDTO();
            copyValues(rec, testRec);
            userService.remove(testRec, new AsyncCallback<UserDTO>()
            {
                @Override
                public void onFailure(Throwable caught)
                {
                    response.setStatus(RPCResponse.STATUS_FAILURE);
                    processResponse(requestId, response);
                    SC.say("Updated Member", "Member has not been updated!");
                }
    
                @Override
                public void onSuccess(UserDTO result)
                {
                    ListGridRecord[] list = new ListGridRecord[1];
                    // We do not receive removed record from server.
                    // Return record from request.
                    list[0] = rec;
                    response.setData(list);
                    processResponse(requestId, response);
                    SC.say("Updated Member", "Member has been successfully updated!");
                }
            });
        }
    
        // *************************************************************************************
        // *************************************************************************************
    
        @Override
        protected void executeFetch(final String requestId, DSRequest request, final DSResponse response)
        {
    
            // for this example I will do "paging" on client side
            final int startIndex = (request.getStartRow() < 0) ? 0 : request.getStartRow();
            final int endIndex = (request.getEndRow() == null) ? -1 : request.getEndRow();
    
            userService.fetch(new AsyncCallback<List<UserDTO>>()
            {
                public void onFailure(Throwable caught)
                {
                    caught.printStackTrace();
                    response.setStatus(RPCResponse.STATUS_FAILURE);
                    processResponse(requestId, response);
                }
    
                public void onSuccess(List<UserDTO> result)
                {
                    // Calculating size of return list
                    int size = result.size();
                    if (endIndex >= 0)
                    {
                        if (endIndex < startIndex)
                        {
                            size = 0;
                        }
                        else
                        {
                            size = endIndex - startIndex + 1;
                        }
                    }
                    // Create list for return - it is just requested records
                    ListGridRecord[] list = new ListGridRecord[size];
                    if (size > 0)
                    {
                        for (int i = 0; i < result.size(); i++)
                        {
                            if (i >= startIndex && i <= endIndex)
                            {
                                ListGridRecord record = new ListGridRecord();
                                copyValues(result.get(i), record);
                                list[i - startIndex] = record;
                            }
                        }
                    }
                    response.setStatus(RPCResponse.STATUS_SUCCESS);
                    response.setData(list);
                    // IMPORTANT: for paging to work we have to specify size of full
                    // result set
                    if (endIndex > result.size())
                    {
                        response.setEndRow(result.size());
                    }
                    response.setTotalRows(result.size());
                    processResponse(requestId, response);
                }
            });
        }
    
        @Override
        protected void executeUpdate(final String requestId, DSRequest request, final DSResponse response)
        {
            // Retrieve record which should be updated
            JavaScriptObject data = request.getData();
            final ListGridRecord rec = new ListGridRecord(data);
            UserDTO testRec = new UserDTO();
            copyValues(rec, testRec);
            userService.update(testRec, new AsyncCallback<UserDTO>()
            {
                @Override
                public void onFailure(Throwable caught)
                {
                    response.setStatus(RPCResponse.STATUS_FAILURE);
                    processResponse(requestId, response);
                    SC.say("Updated Member", "Member has not been updated!");
                }
    
                @Override
                public void onSuccess(UserDTO result)
                {
                    ListGridRecord[] list = new ListGridRecord[1];
                    // We do not receive removed record from server.
                    // Return record from request.
                    list[0] = rec;
                    response.setData(list);
                    processResponse(requestId, response);
                    SC.say("Updated Member", "Member has been successfully updated!");
                }
            });
        }
    
        // *************************************************************************************
        // *************************************************************************************
    
        private void copyValues(ListGridRecord from, UserDTO to)
        {
            to.setUserId(from.getAttributeAsInt(userIdField.getName()));
            to.setActive(from.getAttributeAsBoolean(userActiveField.getName()));
            to.setFullName(from.getAttributeAsString(userFullNameField.getName()));
            // ================================================================================
            to.setUsername(from.getAttributeAsString(usernameField.getName()));
            to.setPassword(from.getAttributeAsString(passwordField.getName()));
            // ================================================================================
            to.setPrefix(from.getAttributeAsString(userPrefixField.getName()));
            to.setFirstName(from.getAttributeAsString(userFirstNameField.getName()));
            to.setMiddleName(from.getAttributeAsString(userMiddleNameField.getName()));
            to.setLastName(from.getAttributeAsString(userLastNameField.getName()));
            to.setSuffix(from.getAttributeAsString(userSuffixField.getName()));
            // ================================================================================
            to.setAddress1(from.getAttributeAsString(address1Field.getName()));
            to.setAddress2(from.getAttributeAsString(address2Field.getName()));
            to.setCity(from.getAttributeAsString(cityField.getName()));
            to.setState(from.getAttributeAsString(stateField.getName()));
            to.setZip(from.getAttributeAsString(zipField.getName()));
            // ================================================================================
            to.setHomeEmail(from.getAttributeAsString(userHomeEmailField.getName()));
            to.setWorkEmail(from.getAttributeAsString(userWorkEmailField.getName()));
            // ================================================================================
            to.setHomePhone(from.getAttributeAsString(userHomePhoneField.getName()));
            to.setWorkPhone(from.getAttributeAsString(userWorkPhoneField.getName()));
            to.setMobilePhone(from.getAttributeAsString(userMobilPhoneField.getName()));
            // ================================================================================
            to.setSecurityQuestion1(from.getAttributeAsString(userQuestion1Field.getName()));
            to.setSecurityAnswer1(from.getAttributeAsString(userAnswer1Field.getName()));
            to.setSecurityQuestion2(from.getAttributeAsString(userQuestion2Field.getName()));
            to.setSecurityAnswer2(from.getAttributeAsString(userAnswer2Field.getName()));
            // ================================================================================
            to.setDob(from.getAttributeAsDate(userBirthdateField.getName()));
            to.setDateJoined(from.getAttributeAsDate(userJoinedField.getName()));
            to.setDateLeft(from.getAttributeAsDate(userLeftField.getName()));
            // ================================================================================
            String[] roles = from.getAttributeAsStringArray(userRolesField.getName());
            ArrayList<UserRoleDTO> userRoleList = new ArrayList<UserRoleDTO>();
            for (String roleId : roles)
            {
                UserRoleDTO userRoleDto = new UserRoleDTO();
    
                RoleDTO role = new RoleDTO();
                role.setRoleId(Long.parseLong(roleId));
    
                userRoleDto.setRole(role);
                userRoleList.add(userRoleDto);
            }
            to.setRoles(userRoleList);
        }
    
        private static void copyValues(UserDTO from, ListGridRecord to)
        {
            to.setAttribute(Constants.USER_ID, from.getUserId());
            to.setAttribute(Constants.USER_ACTIVE, from.isActive());
            to.setAttribute(Constants.USER_FULL_NAME, from.getFullName());
            // ================================================================================
            to.setAttribute(Constants.USER_USERNAME, from.getUsername());
            to.setAttribute(Constants.USER_PASSWORD, from.getPassword());
            // ================================================================================
            to.setAttribute(Constants.USER_PREFIX, from.getPrefix());
            to.setAttribute(Constants.USER_FIRST_NAME, from.getFirstName());
            to.setAttribute(Constants.USER_MIDDLE_NAME, from.getMiddleName());
            to.setAttribute(Constants.USER_LAST_NAME, from.getLastName());
            to.setAttribute(Constants.USER_SUFFIX, from.getSuffix());
            // ================================================================================
            to.setAttribute(Constants.USER_ADDRESS1, from.getAddress1());
            to.setAttribute(Constants.USER_ADDRESS2, from.getAddress2());
            to.setAttribute(Constants.USER_CITY, from.getCity());
            to.setAttribute(Constants.USER_STATE, from.getState());
            to.setAttribute(Constants.USER_ZIP, from.getZip());
            // ================================================================================
            to.setAttribute(Constants.USER_BIRTHDATE, from.getDob());
            to.setAttribute(Constants.USER_JOINED_DATE, from.getDateJoined());
            to.setAttribute(Constants.USER_LEFT_DATE, from.getDateLeft());
            // ================================================================================
            to.setAttribute(Constants.USER_HOME_EMAIL, from.getHomeEmail());
            to.setAttribute(Constants.USER_WORK_EMAIL, from.getWorkEmail());
            // ================================================================================
            to.setAttribute(Constants.USER_HOME_PHONE, from.getHomePhone());
            to.setAttribute(Constants.USER_WORK_PHONE, from.getWorkPhone());
            to.setAttribute(Constants.USER_MOBIL_PHONE, from.getMobilePhone());
            // ================================================================================
            int[] roles = new int[from.getRoles().size() + 1];
            int i = 1;
            roles[0] = (int) from.getUserId();
            for (UserRoleDTO userRoleDto : from.getRoles())
            {
                roles[i++] = (int) userRoleDto.getRole().getRoleId();
            }
            to.setAttribute(Constants.USER_ROLES, roles);
        }
    
        private ListGridRecord getEditedRecord(DSRequest request)
        {
            // Retrieving values before edit
            JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject("oldValues");
            // Creating new record for combining old values with changes
            ListGridRecord newRecord = new ListGridRecord();
            // Copying properties from old record
            JSOHelper.apply(oldValues, newRecord.getJsObj());
            // Retrieving changed values
            JavaScriptObject data = request.getData();
            // Apply changes
            JSOHelper.apply(data, newRecord.getJsObj());
            return newRecord;
        }
    
    }
    Code:
    package com.opensource.troop22.client.tabs.admin;
    
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.event.shared.EventBus;
    import com.opensource.troop22.client.datasources.UserDS;
    import com.opensource.troop22.client.widgets.DateItemWidget;
    import com.opensource.troop22.shared.Constants;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.types.Alignment;
    import com.smartgwt.client.types.Side;
    import com.smartgwt.client.types.TitleOrientation;
    import com.smartgwt.client.util.KeyCallback;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Button;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.CheckboxItem;
    import com.smartgwt.client.widgets.form.fields.HiddenItem;
    import com.smartgwt.client.widgets.form.fields.PasswordItem;
    import com.smartgwt.client.widgets.form.fields.SectionItem;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
    import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.tab.Tab;
    import com.smartgwt.client.widgets.tab.TabSet;
    
    public class MembersTabViewImpl implements MembersTabView
    {
        final Tab membersTab = new Tab();
    
        UserDS membersDS = UserDS.getInstance();
    
        final ListGrid membersGrid = new ListGrid();
    
        private ListGridField idField = new ListGridField(Constants.USER_ID, Constants.TITLE_USER_ID);
        private ListGridField lastNameField = new ListGridField(Constants.USER_LAST_NAME, Constants.TITLE_USER_LAST_NAME);
        private ListGridField firstNameField =
            new ListGridField(Constants.USER_FIRST_NAME, Constants.TITLE_USER_FIRST_NAME);
        private ListGridField activeField = new ListGridField(Constants.USER_ACTIVE, Constants.TITLE_USER_ACTIVE);
    
        final DynamicForm memberForm = new DynamicForm();
    
        private Button newButton;
        private Button resetButton;
        private Button saveButton;
        private Button refreshButton;
    
        private HiddenItem memberIdItem;
        private SelectItem selectPrefixItem;
        private TextItem firstNameItem;
        private TextItem middleNameItem;
        private TextItem lastNameItem;
        private SelectItem selectSuffixItem;
        private CheckboxItem activeItem;
        private DateItemWidget birthdateItem;
        private TextItem address1Item;
        private TextItem address2Item;
        private SelectItem citySelectItem;
        private SelectItem stateSelectItem;
        private TextItem zipcodeItem;
        private DateItemWidget dateJoinedItem;
        private DateItemWidget dateLeftItem;
        private TextItem homePhoneItem;
        private TextItem homeEmailItem;
        private TextItem workPhoneItem;
        private TextItem workEmailItem;
        private TextItem mobilePhoneItem;
        private TextItem usernameItem;
        private PasswordItem passwordItem;
        private TextItem securityQuestion1Item;
        private TextItem securityAnswer1Item;
        private TextItem securityQuestion2Item;
        private TextItem securityAnswer2Item;
    
        private String memberId = "-1";
    
        private final EventBus eventBus;
    
        UserMeritBadgeTabPresenter userMeritBadgeTabPresenter;
    
        public MembersTabViewImpl(String ID, EventBus eventBus)
        {
            this.eventBus = eventBus;
    
            if (!GWT.isScript())
            {
                KeyIdentifier debugKey = new KeyIdentifier();
                debugKey.setCtrlKey(true);
                debugKey.setKeyName("D");
                Page.registerKey(debugKey, new KeyCallback()
                {
                    public void execute(String keyName)
                    {
                        SC.showConsole();
                    }
                });
            }
    
            HLayout mainPanel = new HLayout();
            mainPanel.setWidth100();
            mainPanel.setHeight100();
            // mainPanel.setBorder("1px solid red");
    
            membersTab.setTitle(ID);
    
            VLayout spacer0 = new VLayout();
            spacer0.setWidth(30);
    
            mainPanel.addMember(getMemberGridPanel());
            // mainPanel.addMember(spacer0);
            mainPanel.addMember(getMemberTabPanel());
            // mainPanel.addMember(spacer0);
    
            membersTab.setPane(mainPanel);
        }
    
        private VLayout getMemberTabPanel()
        {
            VLayout memberTabPanel = new VLayout();
            memberTabPanel.setAutoHeight();
            memberTabPanel.setWidth100();
            memberTabPanel.setHeight100();
            memberTabPanel.setBorder("5px solid green");
            memberTabPanel.setAlign(Alignment.LEFT);
    
            final TabSet memberTabSet = new TabSet();
            memberTabSet.setTabBarPosition(Side.TOP);
            memberTabSet.setWidth100();
            memberTabSet.setHeight100();
    
            Tab tTab1 = new Tab("Member Info");
            tTab1.setPane(getMemberFormPanel());
            memberTabSet.addTab(tTab1);
    
            Tab tTab2 = new Tab("Member Roles");
            // tTab2.setPane(getMeritBadgeReqLayout());
            memberTabSet.addTab(tTab2);
    
            Tab tTab3 = new Tab("Member Positions");
            // tTab3.setPane(getMeritBadgeReqLayout());
            memberTabSet.addTab(tTab3);
    
            Tab tTab4 = new Tab("Member Awards");
            // tTab4.setPane(getMeritBadgeReqLayout());
            memberTabSet.addTab(tTab4);
    
    // userMeritBadgeTabPresenter =
    // new UserMeritBadgeTabPresenter(eventBus, new UserMeritBadgeTabViewImpl("Member MB"));
    // memberTabSet.addTab(userMeritBadgeTabPresenter.getView().getUserMeritBadgeTab());
    
            memberTabPanel.addMember(memberTabSet);
    
            return memberTabPanel;
        }
    
        private HLayout getMemberButtonPanel()
        {
            HLayout memberButtonPanel = new HLayout();
            // memberButtonPanel.setBorder("5px solid red");
            memberButtonPanel.setAutoWidth();
            memberButtonPanel.setAutoHeight();
            memberButtonPanel.setMembersMargin(30);
            memberButtonPanel.setLayoutAlign(Alignment.CENTER);
    
            newButton = new Button(Constants.BUTTON_NEW);
            resetButton = new Button(Constants.BUTTON_RESET);
            saveButton = new Button(Constants.BUTTON_SAVE);
            refreshButton = new Button(Constants.BUTTON_REFRESH);
    
            memberButtonPanel.addMember(newButton);
            memberButtonPanel.addMember(resetButton);
            memberButtonPanel.addMember(saveButton);
            memberButtonPanel.addMember(refreshButton);
    
            return memberButtonPanel;
        }
    
        private VLayout getMemberGridPanel()
        {
            VLayout memberGridPanel = new VLayout();
            memberGridPanel.setAutoHeight();
            memberGridPanel.setWidth(340);
            memberGridPanel.setHeight100();
            memberGridPanel.setBorder("5px solid blue");
    
            memberGridPanel.addMember(getMemberGrid());
    
            return memberGridPanel;
        }
    
        private VLayout getMemberFormPanel()
        {
            VLayout memberFormPanel = new VLayout();
            memberFormPanel.setAutoHeight();
            memberFormPanel.setWidth("50%");
            memberFormPanel.setHeight100();
            memberFormPanel.setBorder("5px solid green");
            memberFormPanel.setAlign(Alignment.LEFT);
    
            VLayout spacer1 = new VLayout();
            spacer1.setWidth(30);
    
            memberFormPanel.addMember(getMemberForm());
            memberFormPanel.addMember(spacer1);
            memberFormPanel.addMember(getMemberButtonPanel());
    
            return memberFormPanel;
        }
    
        private ListGrid getMemberGrid()
        {
            idField.setHidden(true);
    
            lastNameField.setCanEdit(false);
            lastNameField.setWidth(130);
    
            firstNameField.setCanEdit(false);
            firstNameField.setWidth(130);
    
            activeField.setCanEdit(false);
            activeField.setWidth(40);
    
            membersGrid.setWidth100();
            membersGrid.setFields(idField, lastNameField, firstNameField, activeField);
            membersGrid.setDataSource(membersDS);
            membersGrid.setAutoFetchData(true);
            // membersGrid.setBorder("1px solid green");
    
            membersGrid.addRecordClickHandler(new RecordClickHandler()
            {
    
                @Override
                public void onRecordClick(RecordClickEvent event)
                {
                    memberForm.reset();
                    memberForm.editSelectedData(membersGrid);
    
                    Record record = event.getRecord();
    
                    memberId = record.getAttributeAsString(Constants.USER_ID);
                    String memberUsername = record.getAttributeAsString(Constants.USER_FULL_NAME);
    
                    userMeritBadgeTabPresenter.refreshUserMeritBadgeGrid(memberId, memberUsername);
                    // userMeritBadgeWidget.refreshUserMeritBadgeGrid(memberId, memberUsername);
                }
    
            });
    
            return membersGrid;
        }
    
        private DynamicForm getMemberForm()
        {
    
            usernameItem = new TextItem(Constants.USER_USERNAME, Constants.TITLE_USER_USERNAME);
            usernameItem.setRequired(true);
            passwordItem = new PasswordItem(Constants.USER_PASSWORD, Constants.TITLE_USER_PASSWORD);
            passwordItem.setRequired(true);
            activeItem = new CheckboxItem(Constants.USER_ACTIVE, "Active");
            activeItem.setDefaultValue(true);
            activeItem.setEndRow(true);
            // ===============================================
            memberIdItem = new HiddenItem(Constants.USER_ID);
            memberIdItem.setDefaultValue(0);
            selectPrefixItem = new SelectItem(Constants.USER_PREFIX, Constants.TITLE_USER_PREFIX);
            selectPrefixItem.setValueMap("Mr.", "Ms.", "Dr.", "Mrs.");
            selectPrefixItem.setEndRow(true);
    
            firstNameItem = new TextItem(Constants.USER_FIRST_NAME, Constants.TITLE_USER_FIRST_NAME);
            firstNameItem.setRequired(true);
    
            middleNameItem = new TextItem(Constants.USER_MIDDLE_NAME, Constants.TITLE_USER_MIDDLE_NAME);
            lastNameItem = new TextItem(Constants.USER_LAST_NAME, Constants.TITLE_USER_LAST_NAME);
            lastNameItem.setRequired(true);
            lastNameItem.setEndRow(true);
    
            selectSuffixItem = new SelectItem(Constants.USER_SUFFIX, Constants.TITLE_USER_SUFFIX);
            selectSuffixItem.setValueMap("Jr.", "III");
            selectSuffixItem.setEndRow(true);
    
            address1Item = new TextItem(Constants.USER_ADDRESS1, Constants.TITLE_USER_ADDRESS1);
            address1Item.setRequired(true);
            address2Item = new TextItem(Constants.USER_ADDRESS2, Constants.TITLE_USER_ADDRESS2);
            address2Item.setRequired(true);
            address2Item.setEndRow(true);
            citySelectItem = new SelectItem(Constants.USER_CITY, Constants.TITLE_USER_CITY);
            citySelectItem.setRequired(true);
            stateSelectItem = new SelectItem(Constants.USER_STATE, Constants.TITLE_USER_STATE);
            stateSelectItem.setRequired(true);
            zipcodeItem = new TextItem(Constants.USER_ZIP, Constants.TITLE_USER_ZIP);
            zipcodeItem.setRequired(true);
    
            // ===============================================
            birthdateItem =
                new com.opensource.troop22.client.widgets.DateItemWidget(Constants.USER_BIRTHDATE,
                    Constants.TITLE_USER_BIRTHDATE);
            birthdateItem.setRequired(true);
            dateJoinedItem = new DateItemWidget(Constants.USER_JOINED_DATE, Constants.TITLE_USER_JOINED_DATE);
            dateLeftItem = new DateItemWidget(Constants.USER_LEFT_DATE, Constants.TITLE_USER_LEFT_DATE);
            dateLeftItem.setEndRow(true);
            // ===============================================
            homePhoneItem = new TextItem(Constants.USER_HOME_PHONE, Constants.TITLE_USER_HOME_PHONE);
            homePhoneItem.setRequired(true);
            workPhoneItem = new TextItem(Constants.USER_WORK_PHONE, Constants.TITLE_USER_WORK_PHONE);
            mobilePhoneItem = new TextItem(Constants.USER_MOBIL_PHONE, Constants.TITLE_USER_MOBIL_PHONE);
            mobilePhoneItem.setEndRow(true);
            homeEmailItem = new TextItem(Constants.USER_HOME_EMAIL, Constants.TITLE_USER_HOME_EMAIL);
            workEmailItem = new TextItem(Constants.USER_WORK_EMAIL, Constants.TITLE_USER_WORK_EMAIL);
            workEmailItem.setEndRow(true);
            // ===============================================
            securityQuestion1Item =
                new TextItem(Constants.USER_SECURITY_QUESTION_1, Constants.TITLE_USER_SECURITY_QUESTION_1);
            securityQuestion1Item.setVisible(false);
            securityQuestion1Item.setDefaultValue("_");
    
            securityAnswer1Item = new TextItem(Constants.USER_SECURITY_ANSWER_1, Constants.TITLE_USER_SECURITY_ANSWER_1);
            securityAnswer1Item.setVisible(false);
            securityAnswer1Item.setDefaultValue("_");
    
            securityQuestion2Item =
                new TextItem(Constants.USER_SECURITY_QUESTION_2, Constants.TITLE_USER_SECURITY_QUESTION_2);
            securityQuestion2Item.setVisible(false);
            securityQuestion2Item.setDefaultValue("_");
    
            securityAnswer2Item = new TextItem(Constants.USER_SECURITY_ANSWER_2, Constants.TITLE_USER_SECURITY_ANSWER_2);
            securityAnswer2Item.setVisible(false);
            securityAnswer2Item.setDefaultValue("_");
            // ===============================================
    
            SectionItem sectionUser = new SectionItem();
            sectionUser.setDefaultValue(Constants.MEMBER_SECTION_USERPASS);
            sectionUser.setSectionExpanded(true);
            sectionUser.setItemIds(Constants.USER_USERNAME, Constants.USER_PASSWORD, Constants.USER_ACTIVE);
    
            SectionItem sectionName = new SectionItem();
            sectionName.setDefaultValue(Constants.MEMBER_SECTION_NAME);
            sectionName.setSectionExpanded(true);
            sectionName.setItemIds(Constants.USER_ID, Constants.USER_PREFIX, Constants.USER_FIRST_NAME,
                Constants.USER_MIDDLE_NAME, Constants.USER_LAST_NAME, Constants.USER_SUFFIX);
    
            SectionItem sectionAddress = new SectionItem();
            sectionAddress.setDefaultValue(Constants.MEMBER_SECTION_ADDRESS);
            sectionAddress.setSectionExpanded(true);
            sectionAddress.setItemIds(Constants.USER_ADDRESS1, Constants.USER_ADDRESS2, Constants.USER_CITY,
                Constants.USER_STATE, Constants.USER_ZIP);
    
            SectionItem sectionDates = new SectionItem();
            sectionDates.setDefaultValue(Constants.MEMBER_SECTION_DATES);
            sectionDates.setSectionExpanded(true);
            sectionDates.setItemIds(Constants.USER_BIRTHDATE, Constants.USER_JOINED_DATE, Constants.USER_LEFT_DATE);
    
            SectionItem sectionOther = new SectionItem();
            sectionOther.setDefaultValue(Constants.MEMBER_SECTION_EMAILS);
            sectionOther.setSectionExpanded(true);
            sectionOther.setItemIds(Constants.USER_HOME_PHONE, Constants.USER_WORK_PHONE, Constants.USER_MOBIL_PHONE,
                Constants.USER_HOME_EMAIL, Constants.USER_WORK_EMAIL);
    
            memberForm.setWidth100();
            memberForm.setTitleWidth(200);
            memberForm.setNumCols(6);
            memberForm.setDataSource(membersDS);
            memberForm.setTitleOrientation(TitleOrientation.TOP);
            memberForm.setTitleWidth(50);
    
            memberForm.setFields(sectionUser, usernameItem, passwordItem, activeItem, sectionName, memberIdItem,
                selectPrefixItem, firstNameItem, middleNameItem, lastNameItem, selectSuffixItem, sectionAddress,
                address1Item, address2Item, citySelectItem, stateSelectItem, zipcodeItem, sectionDates, birthdateItem,
                dateJoinedItem, dateLeftItem, sectionOther, homePhoneItem, workPhoneItem, mobilePhoneItem, homeEmailItem,
                workEmailItem, securityQuestion1Item, securityAnswer1Item, securityQuestion2Item, securityAnswer2Item);
    
            return memberForm;
        }
    
        @Override
        public Tab getMembersTab()
        {
            return membersTab;
        }
    
        @Override
        public int getMemberId()
        {
            return (Integer) this.memberIdItem.getValue();
        }
    
        @Override
        public void addNewMember()
        {
            memberForm.editNewRecord();
        }
    
        @Override
        public void resetMemberForm()
        {
            memberForm.clearValues();
        }
    
        @Override
        public void refreshMemberGrid()
        {
            membersGrid.invalidateCache();
            membersGrid.fetchData();
            memberForm.clearValues();
        }
    
        @Override
        public void saveMember()
        {
            memberForm.saveData();
            memberForm.reset();
            membersGrid.invalidateCache();
            membersGrid.fetchData();
        }
    
    }
    Last edited by tholmes66; 4 Jan 2013, 06:32.

    #2
    I have got the same error as you :/

    Comment


      #3
      Use the most recent patched build (or indicate your version so that it's clear that you are).

      For JavaScript errors, use the instructions in the FAQ to obtain a stack trace (these instructions specify particular browsers to use).

      Please also indicate if you too are using GWT-RPC. And for completeness, please read the FAQ on why using GWT-RPC is a really bad idea.

      Comment


        #4
        Also just a note that the GWT stack posted by the first user shows that there is a crash that results from SmartGWT's UncaughtExceptionHandler in SmartGWTEntryPoint.java:

        at com.google.gwt.user.client.Window.alert(Window.java)
        at com.smartgwt.client.SmartGwtEntryPoint$1.onUncaughtException(SmartGwtEntryPoint.java:303)
        But if you look at the code, there is no possible way that our call to Window.alert() could be invalid in such a way that Window.alert() should crash. So this looks like it may be some internal GWT issue, possibly fixable by upgrading your GWT SDK or clearing your GWT unitcache.

        Comment

        Working...
        X