Having trouble with focus (solved)

UI Components for JSF
Post Reply
luizbarbosa
Posts: 4
Joined: 07 Jul 2010, 22:57

08 Jul 2010, 14:05

Hi,
I am new to PrimeFaces and having problems to set focus.
I have some views. In each view I would like to set focus to one inputtext.

Just the first one get the focus (in the home view).

Can anyone explain what I am doing wrong? :?
I'm using <p:focus for = "textID"/>

best regards,

Luiz
Last edited by luizbarbosa on 22 Jul 2010, 14:09, edited 1 time in total.
NetBeans IDE 6.9, Mojarra 2.0.2, JSF-2.0, and PrimeFaces-2.0.2 on GlassFish v3

User avatar
michiel
Posts: 240
Joined: 07 Jun 2010, 09:12
Location: Belgium

08 Jul 2010, 14:15

you need to provide some more info (Forum Posting Guidelines).

some more code (xhtml and managedBean)?
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)

luizbarbosa
Posts: 4
Joined: 07 Jul 2010, 22:57

08 Jul 2010, 16:22

Hi,

my index.xhtml:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:i="http://primefaces.prime.com.tr/touch"
        contentType="text/html"
        xmlns:p="http://primefaces.prime.com.tr/ui"
        xmlns:ui="http://java.sun.com/jsf/facelets">
    
    <i:application >
        <i:view id="vHome" title="wMove">
            <p:messages globalOnly="true"/>
            <h:form>
                <h:outputLabel value="#{funcionarioMB.logado?funcionarioMB.funcionario.nome:''}"/><p></p>
                <i:tableView>
                    <i:rowGroup >
                        <i:rowItem value="#{funcionarioMB.logado?'Logout':'Login'}" view="vLogin" actionListener="document.getElementById('fLogin:iMat').focus();" />
                        <i:rowItem value="Movimentacao" view="vMovimentacao" rendered="#{funcionarioMB.logado}"/>
                    </i:rowGroup>
                </i:tableView>
            </h:form>
        </i:view>

        <i:view id="vLogin" title="wMove" >
            <f:facet name="leftNavBar">
                <i:navBarControl label="Volta" view="vHome" type="button" effect="slideup"/>
            </f:facet>
            <h:form id="fLogin" title="wMove"  >
                <i:tableView>
                    <i:rowGroup title="Matricula:">
                        <i:rowItem>
                            <h:inputText id ="matricula" value="#{funcionarioMB.funcionario.matricula}"/>
                            <p:focus for="matricula"/>
                        </i:rowItem>
                    </i:rowGroup>
                </i:tableView>
                <h:commandLink actionListener="#{funcionarioMB.login}"  style="margin:0 10px;" styleClass="whiteButton">Confirma</h:commandLink>
            </h:form>
        </i:view>

        <i:view id="vMovimentacao" title="wMove">
            <f:facet name="leftNavBar">
                <i:navBarControl label="Volta" view="vHome" type="button" effect="slideup"/>
            </f:facet>
            <h:form>
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <i:tableView>
                    <i:rowGroup >
                        <i:rowItem value="Etiqueta Origem" view="vOrigem"/>
                        <i:rowItem value="Etiqueta Destino" view="vDestino"/>
                    </i:rowGroup>
                </i:tableView>
            </h:form>
        </i:view>

        <i:view id="vOrigem" title="Etiqueta Origem">
            <f:facet name="leftNavBar">
                <i:navBarControl label="Volta" view="vMovimentacao" type="button" effect="slideup"/>
            </f:facet>
            <h:form id="teste">
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <p:messages />
                <h:inputText id="etqOrigem" value="" />
                <p:focus for="etqOrigem"/>
            </h:form>
        </i:view>

        <i:view id="vDestino" title="Etiqueta Destino"  >
            <f:facet name="leftNavBar">
                <i:navBarControl label="Volta" view="vMovimentacao" type="button" effect="slideup"/>
            </f:facet>
            <h:form id="detDestino" >
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <h:outputLabel value="Descricao"/><p></p>
                <i:tableView>                    
                    <i:rowGroup >                        
                        <i:rowItem>
                        <h:inputText id ="etqDestino" value="" required="true"/>
                        <p:focus for="etqDestino"/>
                        </i:rowItem>
                    </i:rowGroup>
                </i:tableView>                
            </h:form>           
        </i:view>
    </i:application>
</f:view>
best regards,

Luiz
NetBeans IDE 6.9, Mojarra 2.0.2, JSF-2.0, and PrimeFaces-2.0.2 on GlassFish v3

luizbarbosa
Posts: 4
Joined: 07 Jul 2010, 22:57

22 Jul 2010, 14:07

Hi,

I figured out using java script. 8-)

Luiz
NetBeans IDE 6.9, Mojarra 2.0.2, JSF-2.0, and PrimeFaces-2.0.2 on GlassFish v3

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests