Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.richfaces.renderkit.focus;
 
 import  javax.faces.component.UIForm;
 import  javax.faces.context.FacesContext;
 
Strategy for rendering Focus in AbstractFocus.Mode.FORM
    @Override
    public void postAddToView(FacesContext contextAbstractFocus component) {
        UIForm form = (UIForm) .getNestingForm(component);
        FocusRendererUtils.markFormWithFocus(form);
    }
    @Override
    public boolean shouldApply(FacesContext contextAbstractFocus component) {
        if (FocusRendererUtils.isFocusEnforced(context)) {
            return false;
        }
        if (component.isDelayed()) {
            return false;
        }
        UIForm form = (UIForm) .getNestingForm(component);
        if (!context.isPostback()) {
            if (FocusRendererUtils.hasViewFocus(context.getViewRoot())) {
                return false;
            } else if (isSomeAnotherFormFocusRendered(contextcomponent)) {
                return false;
            } else {
                FocusRendererUtils.markFirstFormFocusRendered(contextcomponent);
                return true;
            }
        } else {
            return .isFormSubmitted(contextform);
        }
    }
    private boolean isSomeAnotherFormFocusRendered(FacesContext contextAbstractFocus component) {
        String firstFormFocusRendered = FocusRendererUtils.getFirstFormFocusRendered(context);
        if (firstFormFocusRendered == null) {
            return false;
        }
        return !firstFormFocusRendered.equals(component.getClientId(context));
    }
    @Override
    public String getFocusCandidatesAsString(FacesContext contextAbstractFocus component) {
        UIForm form = (UIForm) .getNestingForm(component);
        if (!context.isPostback()) {
            return form.getClientId(context);
        }
        if (.isFormSubmitted(contextform)) {
            return getFocusCandidatesAsString(contextcomponentform);
        }
        return null;
    }
New to GrepCode? Check out our FAQ X