Search in sources :

Example 1 with PostAddToViewEvent

use of javax.faces.event.PostAddToViewEvent in project liferay-faces-alloy by liferay.

the class CommandLinkRenderer method processEvent.

@Override
public void processEvent(ComponentSystemEvent componentSystemEvent) throws AbortProcessingException {
    CommandLink commandLink = (CommandLink) componentSystemEvent.getComponent();
    // If the specified event indicates that the command link was added to the component tree, then
    if (componentSystemEvent instanceof PostAddToViewEvent) {
        // Add the default Ajax behavior in order to support the ajax attribute. This effectively simulates the
        // presence of a child f:ajax tag.
        RendererUtil.addDefaultAjaxBehavior(commandLink, commandLink.getExecute(), commandLink.getProcess(), "@all", commandLink.getRender(), commandLink.getUpdate(), "@none");
    } else // Otherwise, the specified event indicates that the command link is about to be rendered. If the ajax
    // attribute is true, then ensure that the AjaxBehavior is rendered. Otherwise, ensure that the AjaxBehavior is
    // not rendered.
    {
        AjaxBehavior ajaxBehavior = RendererUtil.getDefaultAjaxBehavior(commandLink);
        ajaxBehavior.setDisabled(!commandLink.isAjax());
    }
}
Also used : PostAddToViewEvent(javax.faces.event.PostAddToViewEvent) CommandLink(com.liferay.faces.alloy.component.commandlink.CommandLink) AjaxBehavior(javax.faces.component.behavior.AjaxBehavior)

Example 2 with PostAddToViewEvent

use of javax.faces.event.PostAddToViewEvent in project liferay-faces-alloy by liferay.

the class CommandButtonRenderer method processEvent.

@Override
public void processEvent(ComponentSystemEvent componentSystemEvent) throws AbortProcessingException {
    CommandButton commandButton = (CommandButton) componentSystemEvent.getComponent();
    // If the specified event indicates that the command button was added to the component tree, then
    if (componentSystemEvent instanceof PostAddToViewEvent) {
        // Add the default Ajax behavior in order to support the ajax attribute. This effectively simulates the
        // presence of a child f:ajax tag.
        RendererUtil.addDefaultAjaxBehavior(commandButton, commandButton.getExecute(), commandButton.getProcess(), "@all", commandButton.getRender(), commandButton.getUpdate(), "@none");
    } else // Otherwise, the specified event indicates that the command button is about to be rendered. If the ajax
    // attribute is true, then ensure that the AjaxBehavior is rendered. Otherwise, ensure that the AjaxBehavior is
    // not rendered.
    {
        AjaxBehavior ajaxBehavior = RendererUtil.getDefaultAjaxBehavior(commandButton);
        ajaxBehavior.setDisabled(!commandButton.isAjax());
    }
}
Also used : PostAddToViewEvent(javax.faces.event.PostAddToViewEvent) CommandButton(com.liferay.faces.alloy.component.commandbutton.CommandButton) AjaxBehavior(javax.faces.component.behavior.AjaxBehavior)

Aggregations

AjaxBehavior (javax.faces.component.behavior.AjaxBehavior)2 PostAddToViewEvent (javax.faces.event.PostAddToViewEvent)2 CommandButton (com.liferay.faces.alloy.component.commandbutton.CommandButton)1 CommandLink (com.liferay.faces.alloy.component.commandlink.CommandLink)1