public AjaxRequestBuilder form(AjaxSource source, UIComponent component, UIForm formComponent) {
        String result = null;

        String form = source.getForm();
        if (LangUtils.isBlank(form)) {
            if (formComponent == null) {
                formComponent = ComponentTraversalUtils.closestForm(component);
            }

            if (formComponent == null) {
                if (context.isProjectStage(ProjectStage.Development)) {
                    String message = "Component '" + component.getClientId(context)
                            + "' should be inside a form or should reference a form via its form attribute."
                            + " We will try to find a fallback form on the client side.";
                    LOG.info(message);
                }
            }
            else {
                result = formComponent.getClientId(context);
            }
        }
        else {
            result = SearchExpressionUtils.resolveClientId(context, component, source.getForm());
        }

        if (result != null) {
            buffer.append(",f:\"").append(result).append("\"");
        }

        return this;
    }
Helper to generate javascript code of an ajax call
primefaces/src/main/java/org/primefaces/util/AjaxRequestBuilder.java