Servoy 5.x Public API

com.servoy.j2db.server.headlessclient.dataui
Class ChangesRecorder

java.lang.Object
  extended by com.servoy.j2db.server.headlessclient.dataui.ChangesRecorder
All Implemented Interfaces:
IStylePropertyChanges

public class ChangesRecorder
extends Object
implements IStylePropertyChanges

This class records the changes for wicket components/beans in ajax mode. It has a setChanged() method for marking the component for render and helper methods for generating the right css properties like location and font

when calling setChanged() on it the component will be re rendered the next time a (ajax) request comes in This can be the ajax polling behavior that every page of a servoy application has if ajax mode is enabled.

When setChanged() is called or any other helper method you have to call setRendered() when the component is rendered again else it will be re rendered for every coming request. This can be done by calling setRendered() from the Component.onAfterRender() that the wicket component needs to override.

the helper methods should be called from javascript methods so that changes done by javascript are reflected in the browser.

Since:
5.0

Constructor Summary
ChangesRecorder()
          default constructor if the component doesnt have default border or padding.
ChangesRecorder(Insets defaultBorder, Insets defaultPadding)
          use this constructor if the component for which this change recorder is made has a default border or padding in the browser.
 
Method Summary
 Dimension calculateWebSize(int width, int height, Border border, Insets margin, int fontSize, Properties properties)
           
 Dimension calculateWebSize(int width, int height, Border border, Insets margin, int fontSize, Properties properties, int valign)
           
 Properties getChanges()
           
 Insets getPaddingAndBorder(int height, Border border, Insets margin, int fontSize, Properties properties)
           
 Insets getPaddingAndBorder(int height, Border border, Insets margin, int fontSize, Properties properties, int valign)
           
 boolean isChanged()
          Returns true if this change recorder is changed and its component will be rendered the next time.
 boolean isValueChanged()
          returns true if its component model object is changed
 void setBgcolor(String bgcolor)
          Adds the background-color css property for the given color to the changed properties set.
 void setBorder(String border)
          Adds the border css property for the given color to the changed properties set.
 void setChanged()
          Set the change flag to true so that the component will be rendered the next time.
 void setChanges(Properties changes)
          Adds all the css properties to the changed set and calls setChanged()
 void setFgcolor(String clr)
          Adds the color css property for the given color to the changed properties set.
 void setFont(String spec)
           
 void setLocation(int x, int y)
          Sets the x,y location css properties to the changed set.
 void setRendered()
          Call this method from the Component.onBeforeRender() call te let the change recorder know it has been rendered.
 void setSize(int width, int height, Border border, Insets margin, int fontSize)
           
 void setSize(int width, int height, Border border, Insets margin, int fontSize, int valign)
           
 void setTransparent(boolean transparent)
          Sets the background-color css property to transparent if the boolean is true, if false then it test if it has to set the bgcolor or remove the background-color property
 void setValueChanged()
          sets the value changed to true so that servoy knows that it is the value object that is changed.
 void setVisible(boolean visible)
           
 void testChanged(org.apache.wicket.Component component, Object value)
          Helper method to see if the value is changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangesRecorder

public ChangesRecorder()
default constructor if the component doesnt have default border or padding.


ChangesRecorder

public ChangesRecorder(Insets defaultBorder,
                       Insets defaultPadding)
use this constructor if the component for which this change recorder is made has a default border or padding in the browser. So that size calculations will take that into account.

Parameters:
defaultBorder -
defaultPadding -
Method Detail

calculateWebSize

public Dimension calculateWebSize(int width,
                                  int height,
                                  Border border,
                                  Insets margin,
                                  int fontSize,
                                  Properties properties)

calculateWebSize

public Dimension calculateWebSize(int width,
                                  int height,
                                  Border border,
                                  Insets margin,
                                  int fontSize,
                                  Properties properties,
                                  int valign)

getChanges

public Properties getChanges()
Specified by:
getChanges in interface IStylePropertyChanges
Returns:
All the current css properties of this component

getPaddingAndBorder

public Insets getPaddingAndBorder(int height,
                                  Border border,
                                  Insets margin,
                                  int fontSize,
                                  Properties properties)

getPaddingAndBorder

public Insets getPaddingAndBorder(int height,
                                  Border border,
                                  Insets margin,
                                  int fontSize,
                                  Properties properties,
                                  int valign)
Parameters:
height -
border -
margin -
fontSize -
properties -
Returns:

isChanged

public boolean isChanged()
Returns true if this change recorder is changed and its component will be rendered the next time.

Specified by:
isChanged in interface IStylePropertyChanges
See Also:
IStylePropertyChanges.isChanged()

isValueChanged

public boolean isValueChanged()
returns true if its component model object is changed

Specified by:
isValueChanged in interface IStylePropertyChanges
See Also:
IStylePropertyChanges.isValueChanged()

setBgcolor

public void setBgcolor(String bgcolor)
Adds the background-color css property for the given color to the changed properties set.

Parameters:
bgcolor -

setBorder

public void setBorder(String border)
Adds the border css property for the given color to the changed properties set.

Parameters:
border -

setChanged

public void setChanged()
Set the change flag to true so that the component will be rendered the next time.

Specified by:
setChanged in interface IStylePropertyChanges

setChanges

public void setChanges(Properties changes)
Adds all the css properties to the changed set and calls setChanged()

Specified by:
setChanges in interface IStylePropertyChanges
Parameters:
changes -

setFgcolor

public void setFgcolor(String clr)
Adds the color css property for the given color to the changed properties set.

Parameters:
clr -

setFont

public void setFont(String spec)
Parameters:
spec -

setLocation

public void setLocation(int x,
                        int y)
Sets the x,y location css properties to the changed set.

Parameters:
x -
y -

setRendered

public void setRendered()
Call this method from the Component.onBeforeRender() call te let the change recorder know it has been rendered.

Specified by:
setRendered in interface IStylePropertyChanges

setSize

public void setSize(int width,
                    int height,
                    Border border,
                    Insets margin,
                    int fontSize)
Parameters:
width -
height -

setSize

public void setSize(int width,
                    int height,
                    Border border,
                    Insets margin,
                    int fontSize,
                    int valign)

setTransparent

public void setTransparent(boolean transparent)
Sets the background-color css property to transparent if the boolean is true, if false then it test if it has to set the bgcolor or remove the background-color property

Parameters:
transparent -

setValueChanged

public void setValueChanged()
sets the value changed to true so that servoy knows that it is the value object that is changed.

Specified by:
setValueChanged in interface IStylePropertyChanges
See Also:
IStylePropertyChanges.setValueChanged()

setVisible

public void setVisible(boolean visible)
Parameters:
visible -

testChanged

public void testChanged(org.apache.wicket.Component component,
                        Object value)
Helper method to see if the value is changed.

Parameters:
component -
value -

Copyright © 2010 Servoy B.V.