Search in sources :

Example 1 with Hyperlink

use of com.sun.webui.jsf.component.Hyperlink in project Payara by payara.

the class WoodstockHandler method dummyHyperlinkArray.

@Handler(id = "dummyHyperlinkArray", output = { @HandlerOutput(name = "links", type = Hyperlink[].class) })
public static void dummyHyperlinkArray(HandlerContext handlerCtx) {
    Hyperlink[] arr = new Hyperlink[1];
    arr[0] = new Hyperlink();
    arr[0].setText(">");
    handlerCtx.setOutputValue("links", arr);
}
Also used : Hyperlink(com.sun.webui.jsf.component.Hyperlink) Handler(com.sun.jsftemplating.annotation.Handler)

Example 2 with Hyperlink

use of com.sun.webui.jsf.component.Hyperlink in project Payara by payara.

the class WoodstockHandler method createHyperlinkArray.

@Handler(id = "createHyperlinkArray", output = { @HandlerOutput(name = "links", type = Hyperlink[].class) })
public static void createHyperlinkArray(HandlerContext handlerCtx) {
    FacesContext ctx = handlerCtx.getFacesContext();
    ExternalContext extCtx = ctx.getExternalContext();
    Map<String, String[]> reqParams = extCtx.getRequestParameterValuesMap();
    String[] linkText = reqParams.get("text");
    String[] linkUrl = reqParams.get("urls");
    if (linkText == null) {
        // No data!  Should we add something here anyway?
        return;
    }
    int len = linkText.length;
    Hyperlink[] arr = new Hyperlink[len];
    String url = null;
    String ctxPath = extCtx.getRequestContextPath();
    int ctxPathSize = ctxPath.length();
    for (int idx = 0; idx < len; idx++) {
        // FIXME: Set parent
        arr[idx] = new Hyperlink();
        arr[idx].setId("bcLnk" + idx);
        // Set rendererType to avoid using widget renderer!!
        arr[idx].setRendererType("com.sun.webui.jsf.Hyperlink");
        arr[idx].setText(linkText[idx]);
        url = linkUrl[idx];
        if (url.startsWith(ctxPath)) {
            url = url.substring(ctxPathSize);
        }
        arr[idx].setUrl(url);
    }
    handlerCtx.setOutputValue("links", arr);
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) Hyperlink(com.sun.webui.jsf.component.Hyperlink) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

Handler (com.sun.jsftemplating.annotation.Handler)2 Hyperlink (com.sun.webui.jsf.component.Hyperlink)2 ExternalContext (javax.faces.context.ExternalContext)1 FacesContext (javax.faces.context.FacesContext)1