Hybrid View

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    3
    Vote Rating
    0
    ngjiajun is on a distinguished road

      0  

    Default Unanswered: Validation Message not appear on Statusbar

    Unanswered: Validation Message not appear on Statusbar


    hi, i have some doubts on the validation message not standardize on the statusbar not sure


    whether i code the correct way or the methods i pass is correct.

    for example: if empty fields submit, the validation error message will appear but however when i come to error message reply form the controller the error message is not standard as the empty fields submit.

    therefore need some helps on how to edit it to standard the message.


    currently my html page are as follow


    HTML Code:
    html><head>    <title>Hello Ext</title>    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">    <link rel="stylesheet" type="text/css" 
    href="extjs/examples/ux/statusbar/css/statusbar.css">    <script type="text/javascript" src="extjs/ext-all.js"></script>    <script type="text/javascript">      var statusbarmsg = "${status}";      if (statusbarmsg == null || statusbarmsg =="")          statusbarmsg = "Form Ready";    </script>    <script type="text/javascript" src="app.js"></script>  <script type="text/javascript" src="extjs/examples/ux/statusbar/StatusBar.js"></script></head><body></body></html>



    my app.js as follow


    Code:
     Ext.require([    
            'Ext.form.*',
            'Ext.tip.*'
        ]);
        
    Ext.onReady(function() {   
      Ext.QuickTips.init();
    
    
    var form = Ext.create('Ext.form.Panel', {
    id:'frm',
    defaults: {
                    xtype: 'textfield',
                    anchor: '100%',
                 },items: [{
                        xtype: 'textfield',                
                        fieldLabel: 'Email',
                        name: 'email',
                    
                },{
                        xtype: 'textfield',
                        fieldLabel: 'Password',
                        name: password
                    
                }],
    buttons: [{
                  
                    text: 'Submit',
                    handler: fnLogin },{
                    text: 'Reset',
                    handler: function() {
                        form.getForm().reset();
                    }
                }]
    });
    
    
    function fnLogin(){
            Ext.getCmp('frm').on({
                beforeaction: function(){
                        Ext.getCmp('win').body.mask();
                        Ext.getCmp('sbWin').showBusy();
                }
            });
        frm.getForm().submit({
            commandName: 'login', //this will call LoginController.java
            standardSubmit: true.
            method:'POST',
            success: function(){
                Ext.getCmp('win').body.unmask();
                Ext.getCmp('sbWin').setStatus({
                    text:'Login successfully!',
                    iconCls:'x-status-valid' // this does not appear
                });
            },
    
    
            failure: function(form,action){
                // this failure function does not appear at all
                Ext.getCmp('win').body.unmask();
                    if (action.failureType == 'server'){
                            obj = Ext.util.JSON.decode(action.response.responseText);
                            Ext.getCmp('sbWin').setStatus({
                                    text: obj.errors.reason,
                                    iconCls:'x-status-error'
                            });
                    }
                    else {
                            if (typeof(action.response)== 'undefined'){
                                Ext.getCmp('sbWin').setStatus({
                                    text: obj.errors.reason,
                                    iconCls:'x-status-error'
                                });
                            }
                            else {
                                Ext.Msg.alert('Warning', 'Server is unreachable: ' + action.response.responseText);
                            }
                    }
            }
        });
        
    }
    
    
    Ext.create('Ext.window.Window', {
            bodyPadding: 5,
            closable: false,
            resizable: false,
            title: 'Login',
            id:'win',
            width: 325,
            listeners: {
              afterrender: function(component, eOpts) {
                Ext.EventManager.onWindowResize(component.center, component) 
              },
              beforeclose: function(component, eOpts) { 
                Ext.EventManager.removeResizeListener(component.center, component); 
              }
            },
            items: [addUserForm],
            bbar: new Ext.ux.StatusBar({
            text:status,
            id:'sbWin',
            iconCls:'x-status-saved'
            })
          }).show();
    
    
    
    
    });

    my login controller is as below




    Code:
    
    package login.controller;
    
    
    import model.User;
    import java.servlet.ServletException;
    import java.servlet.http.HttpServletRequest;
    import java.servlet.http.HttpServletResponse;
    import java.servlet.http.HttpSession;
    import org.springframework.validation.BindException;
    import org.springframework.validation.Errors;
    import org.springframework.validation.Validator;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.mvc.SimpleFormController;
    import org.springframework.web.servlet.view.RedirectView;
    
    
    
    
    
    
    public class LoginFormController extends SimpleFormController {
    
    
    @Override
    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
        User login = (User) command;
        String loginId = login.getLoginId();
        String pwd = login.getPassword();
        
        if (loginId == null || loginId.length() == 0) {
            request.setAttribute("wrongUser",loginId);
            ModelAndView mav = ModelAndView("login.htm");
            mav.addObject("sbWin","Enter userid");
            return mav;
        }
        else if (pwd == null || pwd.length() == 0) {
            request.setAttribute("wrongUser",loginId);
            ModelAndView mav = ModelAndView("login.htm");
            mav.addObject("sbWin","Enter password");
            return mav;
        }
        else {
            
            if (loginId="admin" && pwd ="123"){
                HttpSession session = request.getSession();
                session - request.getSession(true);
                request.setAttribute("loggedAccount",session.getId());
                ModelAndView mav = ModelAndView("user.htm");
                mav.addObject("loginId", loginId);
                return mav;
            }
            else {
                    request.setAttribute("wrongUser",loginId);
                    ModelAndView mav = ModelAndView("login.htm");
                    mav.addObject("sbWin","Enter userId and password");
                    return mav;
            }
        }
    }
    
    
    
    
    }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,408
    Answers
    3549
    Vote Rating
    851
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Have you set a breakpoint to follow the code? Any errors?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread