LayoutUnit gutter attribute unaccounted if collapsible:false

UI Components for JSF
Post Reply
Selaron
Posts: 17
Joined: 30 Nov 2010, 16:13

07 Sep 2011, 09:56

Hello,

I'm using the Layout component of 3.0.M3 snapshot with non-collapsible LayoutUnits and encountered that the gutter attribute is ignored in case of collapsible="false".

This seems to be due to a wrong control flow in LayoutRenderer::encodeUnits() (source code line 104).

Workaround: Create a class extending from LayoutRenderer lik this:

Code: Select all

public class ExtendedLayoutRenderer extends LayoutRenderer {
    protected void encodeUnits(FacesContext context, Layout layout) throws IOException {
        ResponseWriter writer = context.getResponseWriter();

        for(UIComponent child : layout.getChildren()) {
            if(child.isRendered() && child instanceof LayoutUnit) {
                LayoutUnit unit = (LayoutUnit) child;
                
                writer.write("," + unit.getPosition() + ":{");
                writer.write("paneSelector:'" + ComponentUtils.escapeJQueryId(unit.getClientId(context)) + "'");
                writer.write(",size:'" + unit.getSize() + "'");
                writer.write(",resizable:" + unit.isResizable());

                if(unit.getMinSize() != 50) writer.write(",minSize:" + unit.getMinSize());
                if(unit.getMaxSize() != 0) writer.write(",maxSize:" + unit.getMaxSize());

                writer.write(",spacing_open:" + unit.getGutter());
                if(unit.isCollapsible()) {
                    //writer.write(",spacing_open:" + unit.getGutter());
                    writer.write(",spacing_closed:" + unit.getCollapseSize());
                }

                if(!unit.isVisible()) writer.write(",initHidden:true");
                if(unit.isCollapsed()) writer.write(",initClosed:true");

                if(unit.getEffect() != null) writer.write(",fxName:'" + unit.getEffect() + "'");
                if(unit.getEffectSpeed() != null) writer.write(",fxSpeed:'" + unit.getEffectSpeed() + "'");

                if(layout.getResizeTitle() != null) writer.write(",resizerTip:'" + layout.getResizeTitle() + "'");
                if(layout.getExpandTitle() != null) writer.write(",togglerTip_closed:'" + layout.getExpandTitle() + "'");

                writer.write("}");
            }
        }
    }
}

Add to your faces-config.xml:

Code: Select all

<render-kit>
 		<renderer>
			<component-family>org.primefaces.component</component-family>
			<renderer-type>org.primefaces.component.LayoutRenderer</renderer-type>
			<renderer-class>your.package.ExtendedLayoutRenderer</renderer-class>
		</renderer>
 </render-kit>
And finally have a nice day :)

Selaron

jasdanh
Posts: 39
Joined: 12 Mar 2010, 23:44

16 Sep 2011, 00:09

I tried you code and it works great!

Jason Hall

dougCarvalho
Posts: 2
Joined: 28 Jun 2012, 14:43

28 Jun 2012, 14:53

Selaron,

I tried you code and it works for gutter size, but it set collapsible true even if the collapsible is setted false in LayoutUnit component. Am I doing something wrong or this is the way it should happens?

Thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests