[Logo] OLD FORUM - Use new one: https://www.CaptainCasa.online/forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
SPANGRID with dynamic row height sizing - TEXTPANE's height not considered  XML
Forum Index -> Development
Author Message
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5555
Offline

(request by mail, responded via forum)

We have a SPANGRID with TEXTPANEs inside - and expect that the text content drives the height of the corresponding row when setting FIXGRID-DNYAMICHEIGHTSIZING to true. - But: the grid rows are always same size.


Björn Müller, CaptainCasa GmbH
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5555
Offline

TEXTPANE (and TEXTEDITOR) have - unfortunately - a sizing behavior which is a bit differnt to other components:

When defining WIDTH=100% and HEIGHT=100% then the TEXTPANE is sized into the "100%" area. But: the area's height does not grow when the text is too long. - To automatically determine and use the adequate height you need to define WIDTH=100% - and must not define a HEIGHT in addition:

Code:
 NOT auto-growing:
 <t:textpane ... width="100%" height="100%" .../>
 
 WITH auto-height-growing:
 <t:textpane ... width="100%" .../>
 


Now: what does this have to do with the SPANGRID?

In the SPANGRID item you add a component in the following way:
Code:
     public class GridItem extends SPANGRIDItem implements java.io.Serializable
     {
         ...
         public GridItem(...)
         {
             ...
             render();
             ...
         }
         public void render()
         {
             ...
             TEXTPANENode n = new TEXTPANENode()
                 .setBackground("#FFC0C0")
                 .setText(".{summary}")
             addContent(2,n);
             ...
         }
     ...
 

So the component as added with addContent(colspan,componentNode).

Looking into addContent we see...:
Code:
     public void addContent(int colspan, ComponentNode node)
     {
         ...
         if (node.getAttribute("width") == null)
             node.addAttribute("width","100%");
         if (node.getAttribute("height") == null)
             node.addAttribute("height","100%");
         ...
     }
 


So the component automatically receives a HEIGHT of 100% if not set. And this is good for all components - and works "as designed" for the TEXTPANE component... - which means: the TEXT is cut, the sizing is not growing by the content.

So you need to explicitly pass a height in order to overcome this behavior. You cannot set a null-height because the check against the attribute is done with value null... But: you can pass the value Integer.MIN_VALUE which is interpreted on client side in the same way as null.

Update your code to:

Code:
         public void render()
         {
             ...
             TEXTPANENode n = new TEXTPANENode()
                 .setBackground("#FFC0C0")
                 .setText(".{summary}")
                 .setHeight(Integer.MIN_VALUE);
             addContent(2,n);
             ...
         }
 


And the sizing will be correctly done!

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team