JSF Seam way to do a body onload call to JavaScript
dolanp.dolanp.gmail.com Mar 20, 2009 3:14 AMHello,
I have this page:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
template="layout/template.xhtml">
<ui:define name="body">
<body onload="document.getElementById('importMainForm:valueDecoration:upload').focus();">
<h:messages globalOnly="true" styleClass="message"/>
<h:form id="importMainForm" enctype="multipart/form-data">
<rich:panel>
<f:facet name="header">Trading Partner Import</f:facet>
<s:decorate id="valueDecoration" template="layout/edit.xhtml">
<ui:define name="label">XML trading partner import file:
</ui:define>
<s:fileUpload id="upload" data="#{importMain.fileStream}"/>
</s:decorate>
<div style="clear:both"/>
<div style="clear:both"/>
</rich:panel>
<div class="actionButtons">
<h:commandButton id="importMain" value="Next >"
action="#{importMain.importMain}" styleClass="mckSubmit"/>
</div>
</h:form>
</body>
</ui:define>
</ui:composition>
What I want is for the fileUpload input box to be focused when the page loads. This is the only way I've been able to do it but it generates two body tags, one for the <body onload...> that I created and one for the <ui:define name="body"> tag. If I take out the ui:define tag it renders nothing and messes up the whole page. I'm sort of new to JSF so I was just wondering if anyone knew of the "JSF way" to combine the ui:define tag and the body onload so that I'm not duplicating the <body> tag in the rendered page output.
Thanks.
I have this page:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
template="layout/template.xhtml">
<ui:define name="body">
<body onload="document.getElementById('importMainForm:valueDecoration:upload').focus();">
<h:messages globalOnly="true" styleClass="message"/>
<h:form id="importMainForm" enctype="multipart/form-data">
<rich:panel>
<f:facet name="header">Trading Partner Import</f:facet>
<s:decorate id="valueDecoration" template="layout/edit.xhtml">
<ui:define name="label">XML trading partner import file:
</ui:define>
<s:fileUpload id="upload" data="#{importMain.fileStream}"/>
</s:decorate>
<div style="clear:both"/>
<div style="clear:both"/>
</rich:panel>
<div class="actionButtons">
<h:commandButton id="importMain" value="Next >"
action="#{importMain.importMain}" styleClass="mckSubmit"/>
</div>
</h:form>
</body>
</ui:define>
</ui:composition>
What I want is for the fileUpload input box to be focused when the page loads. This is the only way I've been able to do it but it generates two body tags, one for the <body onload...> that I created and one for the <ui:define name="body"> tag. If I take out the ui:define tag it renders nothing and messes up the whole page. I'm sort of new to JSF so I was just wondering if anyone knew of the "JSF way" to combine the ui:define tag and the body onload so that I'm not duplicating the <body> tag in the rendered page output.
Thanks.