cancel
Showing results for 
Search instead for 
Did you mean: 

How to set focus on the plugIn field?

0 Kudos

Hello everybody,

I´m developing an wpmf plugIn with some production information and an input field. When a button in the pod has been clicked this plugIn should start in a selected pod area.

Now, my problem is that I can´t set fecus on the input field of my plugIn. I´ve already tried some javascript in my jsp like

<script type="text/javascript">

                              window.onload =          function(){

                              document.getElementById('myField').focus();

                              };

          </script>

but it doesn´t work. Please help!

Thank you and best regards,

Olga

Accepted Solutions (1)

Accepted Solutions (1)

former_member210324
Participant
0 Kudos

Hello Olga,

please try this method:

          private String getComponentID(String elementId) {

                   UIComponent panel = getContainer();

                    if (panel == null) {

                              return null;

                    }

                    UIComponent comp = findComponent(panel, elementId);

                    if (comp == null) {

                              return null;

                    }

                    return comp.getClientId(FacesContext.getCurrentInstance());

          }

and then call the method "setComponentFocus" from the like this:

          setComponentFocus(getComponentID("FIELDNAME"));

Kind Regards,

Christoph

0 Kudos

Hello Christoph,

thanks for the advice.

I´ve tried your solution but the methode getContaiert() is null by the system. Or should I set a value?

Olga

former_member210324
Participant
0 Kudos

Hello,

the container should be set by the following in the JSP:

<f:subview id="CustomView">

          <ls:panel facet="content" id="container"

                    binding="#{CustomView.container}"

                    title="#{gapiI18nTransformer['CustomView.HEADER']}"

                    hasEditableTitle="false" isCollapsible="false" collapsed="false"

                    enabled="true" headerDesign="STANDARD" areaDesign="TRANSPARENT"

                    borderDesign="BOX" scrollingMode="NONE" isDragHandle="false"

                    contentPadding="NONE" height="100%" width="100%">

                    <f:attribute name="sap-delta-id"                              value="#{sap:toClientId('container')}" />

The red should trigger the setContainer method and then you should be able to use getContainer() and get a value.

Christoph

0 Kudos

Hello Chritoph,

should the container be set in my manged bean or in the backing bean, which is not urgently needed?!

Or can I use my managed bean also as backing bean?

Best regards

former_member210324
Participant
0 Kudos

Hello Olga,

you can use the managed bean.

It should have getContainer/setContainer inheritted from BaseManagedBean.

Christoph

0 Kudos

Hello Christoph,

It works. Thank you!!!

Olga

Answers (0)