0

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.

Community
  • 1
  • 1
Howard
  • 792
  • 8
  • 43

1 Answers1

1

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • You're right, BalusC. I did some searching around here on stackoverflow.com and google.com, and learned this after research, and then about the same time that you answered my question, I was already trying to write some javascript that will get the div.style.display and submit it via p:ajax when 'west' layoutPane is resized, since PrimeFaces Extensions pe:layout has events for open, close, resize. – Howard Nov 06 '12 at 01:32
  • so, I was trying to hack together a solution, which includes h:inputHidden that will pass the div.style.display value to server/bean when p:ajax event="resize" is triggered, but h:inputHidden is not getting updated at all, even if I specify p:ajax partialSubmit="true or false". I recently learned how to use jquery html() method to get/modify inner html, but I don't think that's the best solution here. – Howard Nov 06 '12 at 01:32
  • Google Chrome (panel opened by F12 key) shows me that the style is 'display: none' when the west layout pane is hidden, but div.style.display value via javascript is not reliable for whatever reason, and I'm not liking the behavior or server trips when p:ajax event="resize" is 'rendered' (conditionally) when I'm rendering west layout pane for certain views. Anyway, thanks, and with all respect, I'm not going to worry about trying to use p:ajax event="resize" to update my bean. :) – Howard Nov 06 '12 at 01:33