Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1053

Selectbox doesn't handle onFocus / onBlur event

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 6.0.1
    • 6.0.0
    • Components

      I wrote some code to listen onFocus/onBlur event from Selectbox, but the listener hasn't been notified.
      see following example:

      <zk>
      	<vbox>
      		<hbox>
      			<label value="get focus: " />
      			<label id="current" />
      		</hbox>
      		<hbox>
      			<label value="lost focus: " />
      			<label id="lost" />
      		</hbox>
      		<vbox id="comps">
      			<zscript><![CDATA[
      				ListModel lm = new ListModelArray(new String[]{ "item" });
      			]]>
      				</zscript>
      			<selectbox id="selectbox" model="${lm}" onFocus="current.value = self.id"
      				onBlur="lost.value = self.id" />
      			<checkbox id="checkbox" label="checkbox" onFocus="current.value = self.id"
      				onBlur="lost.value = self.id" />
      		</vbox>
      	</vbox>
      </zk>
      
      

      I traced Selectbox.java and Selectbox has listened onFocus/onBlur event:

      static {
      	addClientEvent(Selectbox.class, Events.ON_SELECT, CE_DUPLICATE_IGNORE
      			| CE_IMPORTANT);
      	addClientEvent(Selectbox.class, Events.ON_FOCUS, CE_DUPLICATE_IGNORE);
      	addClientEvent(Selectbox.class, Events.ON_BLUR, CE_DUPLICATE_IGNORE);
      }
      

      But the service(AuRequest, boolean) method doesn't seems handle onFocus/onBlur event and invoke super.service():

      public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
      	final String cmd = request.getCommand();
      	if (cmd.equals(Events.ON_SELECT)) {
      		_jsel = ((Integer) request.getData().get("")).intValue();
      		final Integer index = ((Integer)request.getData().get(""));
      		final Set<Object> selObjs = new LinkedHashSet<Object>();
      		
      		if (index >= 0)
      			selObjs.add(_model.getElementAt(index));
      		
      		if (_model != null)
      			getSelectableModel().setSelection(selObjs);;
      		
      		Events.postEvent(new SelectEvent(Events.ON_SELECT, this, null, 
      				selObjs, null, index, 0));
      	}
      }
      

            benbai benbai
            paowang paowang
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: