使用richfaces中的选项卡聚焦字段

时间:2012-03-27 05:54:11

标签: richfaces

当a4j:commandbutton点击时,我需要关注selectonemenu。我有以下代码,在这里我需要关注字段,其id为“equipsel”当buuton的id为“aedtls”点击,我尝试使用javascript和jquery没有用请帮帮我

                <rich:tab id="equipmentTab" name="ed" reRender="k1,k2"
                switchType="client"
                label="#{messages['com.infyz.toms.entity.ShipmentEquipmentDetails']}">
                <a4j:outputPanel id="equipmentPanel">
                    <h:outputText value="There are no shipment equipment details"
                        rendered="#{itOfferEquipments.rowCount==0}" />
                    <s:div
                        style="min-height: 10px; max-height: 150px;width:440px; overflow-x:hidden; overflow-y:auto;">
                        <rich:dataTable id="itOfferEquipmentsListTable"
                            rowClasses="odd-row,even-row" var="_shipmentEquipmentDetails"
                            value="#{itOfferEquipments}" cellpadding="0" cellspacing="0"
                            onmouseover="mouseover2()" onmouseout="mouseout2()"
                            width="370px" rendered="#{itOfferEquipments.rowCount > 0}">

                            <rich:column id="machinarymaster" width="200px" sortable="true"
                                headerClass="removeheadergreen">
                                <f:facet name="header">
                                    <h:panelGrid columns="2">
                                        <h:outputText styleClass="headerText"
                                            value="#{messages['com.infyz.toms.properties.Type']}" />
                                        <span class="required">*</span>
                                    </h:panelGrid>
                                </f:facet>
                                <h:selectOneMenu id="equipsel"
                                    value="#{_shipmentEquipmentDetails.icMachinaryMaster}"
                                    style="width:175px" required="true"
                                    requiredMessage="*#{messages['com.infyz.toms.properties.Type']}::--->Value is Required">
                                    <s:selectItems value="#{icMachinaryMasters}" var="machinary"
                                        label="#{machinary.machinaryId}"
                                        noSelectionLabel="#{messages['com.infyz.toms.messages.Click_here_to_select']}" />
                                    <s:convertEntity />
                                    <a4j:support event="onchange"
                                        reRender="machinarymaster,capacity" ajaxSingle="true"
                                        limitToList="true" />
                                </h:selectOneMenu>
                            </rich:column>

                            <rich:column id="capacity" width="60px" sortable="true"
                                headerClass="removeheadergreen">
                                <f:facet name="header">
                                    <h:outputText styleClass="headerText"
                                        value="#{messages['com.infyz.toms.properties.Capacity']}" />
                                </f:facet>
                                <h:inputText
                                    value="#{_shipmentEquipmentDetails.icMachinaryMaster.capacity}"
                                    disabled="true"
                                    style=" width : 60px;#{messages['com.infyz.toms.disablefield.style']}" />

                            </rich:column>

                            <rich:column width="110px" id="quantity"
                                headerClass="removeheadergreen">
                                <f:facet name="header">
                                    <h:outputText styleClass="headerText"
                                        value="#{messages['com.infyz.toms.properties.Quantity']}" />
                                </f:facet>
                                <h:inputText value="#{_shipmentEquipmentDetails.quantity}" >
                                    <a4j:support event="onblur" reRender="quantity" />
                                </h:inputText>
                            </rich:column>

                        </rich:dataTable>
                    </s:div>
                    <ui:include src="/common_activities/tablerowcolor.xhtml">
                        <ui:param name="tableId" value="itOfferEquipmentsListTable" />
                        <ui:param name="mouseovername" value="mouseover2" />
                        <ui:param name="mouseoutname" value="mouseout2" />
                    </ui:include>
                    <ui:include src="/common_activities/datatableselectioncolor.xhtml">
                        <ui:param name="tableId" value="itOfferEquipmentsListTable" />
                    </ui:include>
                    <rich:spacer height="8" />
                    <s:div style="text-align:right;">
                        <a4j:commandButton id="aedtls"
                            action="#{shipmentEquipmentAction.addOfferEquipments}"
                            reRender="equipmentPanel, equipsel"
                            rendered="#{s:hasRole(messages['com.infyz.toms.role.commercial.export.offer.create'])}"
                            onclick="#{rich:component('progressPanel')}.show();"
                            oncomplete="#{rich:component('progressPanel')}.hide(); if (#{facesContext.maximumSeverity!=null}) #{rich:component('messagePanel')}.show();"
                            value="#{messages['com.infyz.toms.label.button.tooltip.Add']} Offer Equipment" />
                        <rich:spacer width="8" />
                        <a4j:commandButton
                            action="#{shipmentEquipmentAction.cancelOfferEquipment}"
                            rendered="#{s:hasRole(messages['com.infyz.toms.role.commercial.export.offer.create'])}"
                            reRender="equipmentPanel" immediate="true"
                            value="#{messages['com.infyz.toms.label.button.tooltip.Cancel']}" />
                    </s:div>
                </a4j:outputPanel>
                <rich:hotKey id="k2"
                    key="#{messages['com.infyz.hotkeys.Insert_new_record']}"
                    handler="#{rich:element('aedtls')}.onclick();return false;"
                    rendered="#{itShipmentOrderAction.selectedTab eq 'ed'}" />
            </rich:tab>

1 个答案:

答案 0 :(得分:0)

您可以使用#{rich:element('equipsel')}获取真实的渲染ID,然后使用该dom元素设置焦点。然后从按钮调用它。 类似的东西:

<script>
    function setFocusToEquipsel() {
        #{rich:element('equipsel')}.focus();
    }
</script>

<a4j:commandButton id="aedtls"
    oncomplete="... ; setFocusToEquipsel();"
/>

我认为这应该有用。

MAG, 米洛