couldn't find focus item: undefined

Since I started Using 2.1 releases, I am getting many “WARN” messages in the “Development Mode” tab.

I would like to clean up my code so that GWT would not generate these warning messages. any FAQ, or references, whatever to help me with these warnings?

No. Just read the individual warnings, see if you understand them and try to correct them that way. If you don’t, search the docs and forums for the warning message to see if it’s already been covered. Finally, post about any warnings that seem to be unique to you and which you don’t understand.

OK, here is one of many.

what is causing this error? If I clink somewhere on the VLayout(canvas) the TextItem loses focus, and clicking in the text area does NOT set the focus.

11:15:17.305 [ERROR] [uarw] 11:15:17.305:MUP5[E]:WARN:DynamicForm:isc_OID_1882:couldn’t find focus item: undefined

I have form with a TextItem which is added to a VLayout with a button.

    	form = new DynamicForm();
    	GWT.log("id="+form.getID(), null);
    	form.setWidth100();
    	form.setAutoFocus(true);
    	form.setNumCols(2);
    	form.setCellSpacing(20);
    	
    	stext = new TextItem();
    	stext.setTitle("Query");
    	stext.setWidth(600);
    	stext.setColSpan(2);
    	stext.setTextAlign(Alignment.LEFT);
    	
    	stext.addKeyPressHandler(new com.smartgwt.client.widgets.form.fields.events.KeyPressHandler() {
			
			@Override
			public void onKeyPress(
					com.smartgwt.client.widgets.form.fields.events.KeyPressEvent event) {
				// TODO Auto-generated method stub
				if (event.getKeyName().equals("Enter"))
					search();
			}
		});
		form.setFields(stext);
    	
		Button sbutton = new Button("Search new", new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				// TODO Auto-generated method stub
				search();
			}
		});
		sbutton.setWidth("100");
		HLayout bhlayout = new HLayout();
		bhlayout.setWidth100();
		bhlayout.setAlign(Alignment.CENTER);
		bhlayout.addMember(sbutton);
				
		return Utils.getVLayout(form, bhlayout);

It’s not clear from the code you provided (we can’t run it - it depends on other code you’ve written). If you can show runnable code that produces the error, we can take a look.

find focus warning

I have seen this also and can replicate it to the following code. The focus is applied correctly to the TextItem in all these browsers (Chrome, IE 7, and FF). Using SmartGWT 2.1 and GWT 2.0.0. But the Warning still appears from the setAutoFocus(true); line.

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;

public class FocusTest implements EntryPoint{

    public void onModuleLoad() {
        TextItem textField = new TextItem();
        textField = new TextItem();
        textField.setTitle("label");
        
        DynamicForm form = new DynamicForm();
        form.setFields(textField);
        form.setAutoFocus(true);
        form.draw();
    }   
}

The following is the complete development mode console log:
10:57:22.843 [ERROR] [w2client] 10:57:22.840:WARN:DynamicForm:isc_OID_2:couldn’t find focus item: undefined
com.smartgwt.client.core.JsObject$SGWT_WARN: 10:57:22.840:WARN:DynamicForm:isc_OID_2:couldn’t find focus item: undefined
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
at com.smartgwt.client.widgets.BaseWidget.draw(BaseWidget.java)
at gov.state.wraps.client.root.client.prototype.FocusTest.onModuleLoad(FocusTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Thread.java:619)

Thanks for the simple test case, we’ll eliminate the bogus warning.