开发者

JSF AjaxStatusTag how to add programmatically

I tried so hard but I just cannot get a simple Richfaces AjaxStatusTag inserted in my page. I generate the components from Java code, not xhtml. That's what I do:

    AjaxStatusTag deleteStatus = new AjaxStatusTag();
    FacetTag start = new FacetTag();
    start.setName("start");
    HtmlGraphicImage pic = new HtmlGraphicImage();
    pic.setUrl("/resources/images/ajaxLoaderLong.gif");
    pic.setAlt("ajaxLoaderLong.gif");
    start.setValue("start", pic); //how to add pic to FacetTag?
    start.setParent(deleteStatus);

I'm not even sure about the FacetTag either... Other cases, eg to have a simple Div with a link it's easy to get the children of the div and then add the link to that collection but AjaxStatusTag and FacetTag are different and I don't have any idea how to solve this.

A开发者_如何学Gony help is appreciated!

cheers, balázs


ok, so I solved it. Here's what I did:

private static void renderAjaxStatus(UIComponent holderRegion, HtmlAjaxCommandLink ajaxLink, String statusID) {

        UIComponent status = FacesContext.getCurrentInstance().getApplication().createComponent(HtmlAjaxStatus.COMPONENT_TYPE);
        status.setId(STATUS_ID + statusID);
        HtmlPanelGroup panelGroup = (HtmlPanelGroup) FacesContext.getCurrentInstance().getApplication().createComponent(HtmlPanelGroup.COMPONENT_TYPE);

        Div div = new Div();
        div.setStyleClass(STATUS_COVER);

        HtmlGraphicImage pic = new HtmlGraphicImage();
        pic.setUrl(RESOURCES_IMAGES_AJAX_LOADER_GIF);
        pic.setAlt(STATUS_ID);
        pic.setStyleClass(STATUS_PIC_STYLECLASS);

        panelGroup.setStyleClass(STATUS_PANEL_STYLECLASS);
        panelGroup.getChildren().add(div);
        panelGroup.getChildren().add(pic);

        deleteStatus.getFacets().put("start", panelGroup);
        holderRegion.getChildren().add(status);

        ajaxLink.setStatus(STATUS_ID + statusID);
}

cheers, balázs

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜