Friday 26 July 2013

How to get parameter map from http request in java.

How to get parameter map from httpServlet request in java.

public static Map<String, String> getRequestMap(HttpServlet request){
         Map<String, String> r = new HashMap<String, String>();
         for (Map.Entry<String, String[]> entry: request.getParameterMap().entrySet()){
           String[] value = entry.getValue();
           if (value !=null && value .length>0) r.put(entry.getKey(), value[0]);
         }
         return r;

       }

Thursday 18 July 2013

How to Handle grid selection model in accordion layout in collapsed mode.

How to Handle grid selection model in accordion layout in collapsed mode.

Problem:   I have three grid which  are within accordion layout. I have to select the record in gird which is collapsed mode first time view is loaded.



We are getting error as view is not available in  collapse mode.

Solution : we need to handle like below code. Need to add listener to grid to select the grid data after grid expanded first time.

Source Code:

    if (grid.collapsed !== true) {
         grid.getSelectionModel().select(recordArray, true, false);
    } else {
      grid.addListener('expand', function() {
         grid.getSelectionModel().select(recordArray, true, false);
         }, grid, {
             single: true
         });
    }

Monday 8 April 2013

How to avoid showing old data on extjs comobox while querying.

Problem:  When I click on combobox. It shows the old data in blur before it display new data. Some time it does not  allow me to select  the combobox.  Those kind of issue will appear only when you load combobox as raw static data and then try to load using query.

Solution:

        xtype: 'combobox',
        name: 'interNalFaeId',
        itemId: 'interNalFaeId',
        fieldLabel: 'Arrow FAE',
        editable: false,
        listeners: {
          beforequery: function(queryEvent) {
            if (queryEvent.combo.lastQuery !== queryEvent.query) {
              queryEvent.combo.store.removeAll();
            }
          },
          scope: me

        }

How to handle special key TAB or ENTER for EXTJs combobox to trigger.

Requirement is to trigger EXTJS combobox to trigger on tab change and press of enter key.
Below code is solution for above requirement.

        xtype: 'partsearchlov',
        name: 'partNumber',
        displayField: 'concatSegPartNum',
        valueField: 'concatSegPartNum',
        fieldLabel: 'Arrow Part',
        allowBlank: false,
        cls: 'required',
        minChars: 2,
        triggerAction: 'query',
        labelWidth: 80,
        listeners: {
          specialkey: function(field, e) {
            var val;
            if (e.getKey() === e.ENTER || e.getKey() === e.TAB) {
              val = field.getRawValue();
              if ( typeof val !== 'undefined') {
                if (val.indexOf('^') !== -1) {
                  val = val.slice(0, val.indexOf('^'));
                }
                field.doQuery(val, true, true);
              }
            }
          },
          scope: me

        }

Thursday 7 March 2013

Git Understanding Image


How to trigger extjs combox on click of ENTER and TAB Key


Problem: I have one combobox, want to trigger the combobox on keypress of      ENTER and TAB key

Solution:  Use specialkey listener to handle ENTER and TAB key then you doQuery() method to trigger combobox.

 Version: EXTJS 4.1
Code:


   listeners: {
        specialKeyfunction(field,e) {
            if(e.getKey() === e.ENTER || e.getKey() === e.TAB){
             field.doQuery(field.getRawValue(),true,true)
            }
         }
    }