Index: C:/work/workspace/icefaces-trunk-ossrepo/component-metadata/src/main/resources/conf/ice_properties/ice-body-props.xml
===================================================================
--- C:/work/workspace/icefaces-trunk-ossrepo/component-metadata/src/main/resources/conf/ice_properties/ice-body-props.xml	(revision 16755)
+++ C:/work/workspace/icefaces-trunk-ossrepo/component-metadata/src/main/resources/conf/ice_properties/ice-body-props.xml	(working copy)
@@ -98,3 +98,14 @@
         </editor-class>
     </property-extension>
 </property>
+<property>
+    <description>
+    </description>
+    <property-name>focus</property-name>
+    <property-extension>
+        <category>ICE_COMPONENT</category>
+        <editor-class>
+            &stringEditor;
+        </editor-class>
+    </property-extension>
+</property>
Index: C:/work/workspace/icefaces-trunk-ossrepo/component/src/com/icesoft/faces/component/ext/renderkit/BodyRenderer.java
===================================================================
--- C:/work/workspace/icefaces-trunk-ossrepo/component/src/com/icesoft/faces/component/ext/renderkit/BodyRenderer.java	(revision 16755)
+++ C:/work/workspace/icefaces-trunk-ossrepo/component/src/com/icesoft/faces/component/ext/renderkit/BodyRenderer.java	(working copy)
@@ -33,15 +33,20 @@
 
 package com.icesoft.faces.component.ext.renderkit;
 
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.w3c.dom.Element;
+
+import com.icesoft.faces.application.D2DViewHandler;
+import com.icesoft.faces.component.ext.HtmlBody;
 import com.icesoft.faces.context.DOMResponseWriter;
+import com.icesoft.faces.context.effects.JavascriptContext;
 import com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer;
 import com.icesoft.faces.renderkit.dom_html_basic.HTML;
-import org.w3c.dom.Element;
 
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-
 public class BodyRenderer extends DomBasicRenderer {
 
     public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {
@@ -54,6 +59,10 @@
         setElementAttr(body, HTML.STYLE_ATTR, uiComponent, HTML.STYLE_ATTR);
         setElementAttr(body, "text", uiComponent, "text");
         setElementAttr(body, "vlink", uiComponent, "vlink");
+        
+        if( ((HtmlBody)uiComponent).getFocus() != null ){
+        	setFocus(((HtmlBody)uiComponent).getFocus(), uiComponent, facesContext);
+        }
     }
 
     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
@@ -65,4 +74,19 @@
             element.setAttribute(elementAttrName, attrValue.toString());
         }
     }
+    
+    public void setFocus(String focus, UIComponent comp, FacesContext fc){
+    	UIComponent target = null;
+    	if( focus.indexOf(':') > -1){
+    		target = comp.findComponent(focus);
+    	}
+    	else{
+    		target = D2DViewHandler.findComponentInView(comp,focus);
+    	}
+    	if( target != null ){
+    		System.out.println("BodyRenderer: applying application focus to " + target.getClientId(fc));
+    		JavascriptContext.applicationFocus(fc,target.getClientId(fc));
+    	}
+    		
+    }
 }
Index: C:/work/workspace/icefaces-trunk-ossrepo/component/src/com/icesoft/faces/component/ext/HtmlBody.java
===================================================================
--- C:/work/workspace/icefaces-trunk-ossrepo/component/src/com/icesoft/faces/component/ext/HtmlBody.java	(revision 16755)
+++ C:/work/workspace/icefaces-trunk-ossrepo/component/src/com/icesoft/faces/component/ext/HtmlBody.java	(working copy)
@@ -12,6 +12,7 @@
     private String style;
     private String text;
     private String vlink;
+    private String focus;
 
     public HtmlBody() {
         super();
@@ -35,6 +36,14 @@
     public String getBackground() {
         return (String) getAttribute("background", background, null);
     }
+    
+    public String getFocus(){
+    	return (String)getAttribute("focus",focus,null);
+    }
+    
+    public void setFocus(String focus){
+    	this.focus = focus;
+    }
 
     public void setBackground(String background) {
         this.background = background;
@@ -99,6 +108,7 @@
                 style,
                 text,
                 vlink,
+                focus,
         };
     }
 
@@ -111,6 +121,7 @@
                 "style",
                 "text",
                 "vlink",
+                "focus",
         };
         Object values[] = (Object[]) state;
         super.restoreState(context, values[0]);
Index: C:/work/workspace/icefaces-trunk-ossrepo/core/src/com/icesoft/faces/application/D2DViewHandler.java
===================================================================
--- C:/work/workspace/icefaces-trunk-ossrepo/core/src/com/icesoft/faces/application/D2DViewHandler.java	(revision 16755)
+++ C:/work/workspace/icefaces-trunk-ossrepo/core/src/com/icesoft/faces/application/D2DViewHandler.java	(working copy)
@@ -900,4 +900,36 @@
         }
         return component;
     }
+    
+    /**
+	 * A version of findComponent() that attempts to locate a component by id (not clientId) 
+	 * and searches into NamingContainers. If there are more than one component with the 
+	 * provided id, the first one found will be returned
+	 * 
+	 * @param uiComponent the base component to search from
+	 * @param componentId the id to search for
+	 */
+
+	public static UIComponent findComponentInView(UIComponent uiComponent,
+			String componentId) {
+		UIComponent component = null;
+		UIComponent child = null;
+
+		if (componentId.equals(uiComponent.getId())) {
+			return uiComponent;
+		}
+		Iterator children = uiComponent.getFacetsAndChildren();
+		while (children.hasNext() && (component == null)) {
+			child = (UIComponent) children.next();
+			component = findComponentInView(child, componentId);
+			if (component != null) {
+				break;
+			}
+			if (componentId.endsWith(child.getId())) {
+				component = child;
+				break;
+			}
+		}
+		return component;
+	}
 }
