Forum Stats

  • 3,838,561 Users
  • 2,262,383 Discussions
  • 7,900,687 Comments

Discussions

When any error popup is closed, focus should get set to in the field in which error is present

User_LUSW8
User_LUSW8 Member Posts: 23 Green Ribbon

Hi,

We have required input fields in our page, when we are not filling all fields and clicking on next button will get error popup. When we close that popup, focus should be set the that field only but focus is going to other actionable item. Please suggest something. Which property to add to set focus on that field in ADF.

I am using Jdev version: Studio Edition Version 12.2.1.4.0

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,585 Red Diamond

    User, show us how you have configured to show the error popup, please.

    How should this work if you have multiple errors?


    Timo

  • User_LUSW8
    User_LUSW8 Member Posts: 23 Green Ribbon

    Hi,

    This is code snnipet for jsff:

    af:panelLabelAndMessage label="#{bindings.FirstName.hints.label}*" id="plam1" styleClass="firstLabel">

              <f:facet name="end">

              <af:inputText value="#{bindings.FirstName.inputValue}" 

                    label="#{bindings.FirstName.hints.label}"

                    simple="true" 

                     required="#{bindings.FirstName.hints.mandatory}"  

                     columns="#{bindings.FirstName.hints.displayWidth}"

                     maximumLength="#{bindings.FirstName.hints.precision}"

                     shortDesc="#{bindings.FirstName.hints.tooltip}" id="it1" 

                     binding="#{backingBeanScope.clauseSearchBackingBean.firstNameBind}">

                <f:validator binding="#{bindings.FirstName.validator}"/>

              </af:inputText>

              </f:facet>

            </af:panelLabelAndMessage>

    And code snnipet for Bean class:

    else if(FirstName==null){     

          FacesContext context = FacesContext.getCurrentInstance();  

          FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Please enter First Name");

          context.addMessage(null, msg);


    Please find Screen shot for reference:


  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,585 Red Diamond

    Have you tried what happens if you set the error message to the component instead of putting it to the global list?

    For this, you have to add the client id of the component to the addMessage method like

    FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_WARN, msgHead , msgDetail);
    facesContext.addMessage(uiComponent.getClientId(facesContext), msg);
    


    Timo

  • User_LUSW8
    User_LUSW8 Member Posts: 23 Green Ribbon

    Have you tried what happens if you set the error message to the component instead of putting it to the global list?

    For this, you have to add the client id of the component to the addMessage method like

    FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_WARN, msgHead , msgDetail);
    facesContext.addMessage(uiComponent.getClientId(facesContext), msg);
    

    What is msgHead here?

  • User_LUSW8
    User_LUSW8 Member Posts: 23 Green Ribbon

    Yes. I have checked the document. In my case what the uiComponent and msgHead? For me, we are passing null

    else if(FirstName==null){     

          FacesContext context = FacesContext.getCurrentInstance();  

          FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Please enter First Name");

          context.addMessage(null, msg);

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,585 Red Diamond

    Sorry, but the doc is pretty clear about the parameters, isn't it?

    The first parameter is the severity, the second parameter is a string that is shown as a summary, and the third is the message detail.

    An easy task is to just put "Hello" as the second parameter and "world" as the third parameter. Then see what happens.

    The next doc to check is the one for FacesContext.addMessage(...)

    Here you can add the clientId of the component the error message should be attached to.


    Timo