Question

I have the following rendered HTML:

<div id="ordersBrowseForm:ordersBrowseWestPane" class="ui-layout-west ui-widget-content ui-corner-all ui-layout-pane ui-layout-pane-west" data-combinedposition="west" style="position: absolute; margin: 0px; left: 0px; right: auto; top: 116px; bottom: 0px; height: 312px; z-index: 0; width: 198px; display: none; visibility: visible; "><div class="ui-widget-header ui-corner-top pe-layout-pane-header">

Since I assigned an ID to this PrimeFaces Extension layoutPane (pe:layoutPane), I would like to check the display CSS from a bean via OmniFaces Components.findComponent and JSF UIComponent.

Based on BalusC's answer on the following:

Accessing attributes passed to extended PrimeFaces component

I have the following in my bean:

UIComponent westPane = (UIComponent) Components.findComponent("ordersBrowseForm:ordersBrowseWestPane");
if (westPane != null) {
    Map attrs = westPane.getAttributes();
    String paneStyle = (String) attrs.get("style");
    if (debug) {
        String log;
        log = "LayoutController.handleResize(): ordersBrowseForm:ordersBrowseWestPane style = " +
              (paneStyle != null ? paneStyle : "null");
        System.out.println(log);
    }
}

Server log always contains the following:

INFO: LayoutController.handleResize(): ordersBrowseForm:ordersBrowseWestPane style = null

Please advise. Thanks.

Was it helpful?

Solution

That's not possible. The UIComponent#getAttributes() returns only attributes which are either explicitly declared on the component in the view side:

<p:someComponent style="position: absolute;">

Or programmatically before or during rendering:

component.getAttributes().put("style", "position: absolute;");

It does not return the attribute of the generated HTML element. It's not entirely clear what you're trying to do, but you might consider to perform the task in the client side instead, using JavaScript.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top