This content has been marked as final.
Show 3 replies
-
1. Re: Set focus on input field, what to do?
lbbishop Oct 10, 2007 5:30 PM (in response to mtaal)I was able to set focus on an input field within richfaces modalpanel (facelets):
<h:form> <!-- add controls here --> <a4j:outputPanel ajaxRendered="true"> <h:panelGrid columns="2"> <h:outputLabel for="ParameterName" value="Parameter Name:" styleClass="label-bold" /> <h:panelGroup> <h:outputText id="ParameterName" value="#{operatorForm.paramName}" styleClass="label"/> </h:panelGroup> <h:outputLabel for="ParameterValue" value="Parameter Value:" styleClass="label-bold" /> <t:inputText id="ParameterValue" value="#{operatorForm.paramValue}" styleClass="label" size="55" maxlength="64" forceId="true"/> <script> document.getElementById('ParameterValue').focus(); </script> </h:panelGrid> </a4j:outputPanel> </h:form>
The modal panel show logic required the focus attribute to get this to work with IE:<a4j:commandLink action="#{operatorForm.editParameterAction}" focus="ParameterValue" onclick="javascript:Richfaces.showModalPanel('paramDlg');" rendered="#{empty sequence.completionDate}">
-
2. Re: Set focus on input field, what to do?
mtaal Oct 11, 2007 5:30 AM (in response to mtaal)Hi,
Thanks for your reply. I am not sure it will work in my case though as the id of the input's get pre-pended with their container id's. Here is an example id:
j_id66:books:bookTitleDecoration:title
(I also use Seam's s:decorate)
As I want to set focus when the form opens I can not use the focus attribute of the richfaces components (afaik).
However as richfaces has this feature of focus in several components there is maybe an easy-to-use jscript function or something which I can use to get to an input without needing to know all the id encoding strategies.
gr. Martin -
3. Re: Set focus on input field, what to do?
dmitry.demyankov Oct 11, 2007 5:46 AM (in response to mtaal)Try setting
prependId="false"
if you're using h:form