Page
In Vorbereitung auf die Ausgabe der Informationen zur Programmversion wird nun ein bebop:pageGenerator erzeugt, sobald HashMap<String, String> m_pageGenerator mit den entsprechenden Informationen gefüllt wird. Dieses geht über die Methode addGeneratorInformation(String key, String value). Fehlt jetzt die Möglichkeit diese Informationen beim Start aus den Metataden auszulesen und immer zu setzen. Dazu muß vermutlich die Struktur noch etwas angepaßt werden. git-svn-id: https://svn.libreccm.org/ccm/trunk@2281 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
2ce26b2386
commit
722a74ce2f
|
|
@ -32,7 +32,6 @@ import com.arsdigita.profiler.Profiler;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.xml.Document;
|
import com.arsdigita.xml.Document;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -43,48 +42,46 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>The top-level container for all Bebop components and containers. </p>
|
* <p>The top-level container for all Bebop components and containers. </p>
|
||||||
*
|
*
|
||||||
* <UL>
|
* <UL> <LI>Holds references to the components of a page.</LI> <LI>Provides
|
||||||
* <LI>Holds references to the components of a page.</LI>
|
* methods for servicing requests and for notifying other components that a
|
||||||
* <LI>Provides methods for servicing requests and for notifying
|
* request for this page has been received through
|
||||||
* other components that a request for this page has been received through
|
|
||||||
* {@link ActionListener ActionListeners}.</LI>
|
* {@link ActionListener ActionListeners}.</LI>
|
||||||
*
|
*
|
||||||
* <LI>Tracks request parameters for stateful components, such as tabbed
|
* <LI>Tracks request parameters for stateful components, such as tabbed panes
|
||||||
* panes and sortable tables.</LI>
|
* and sortable tables.</LI> </UL> <p> A typical
|
||||||
* </UL>
|
* <code>Page</code> may be created as follows: null <blockquote><pre><code>
|
||||||
* <p>
|
|
||||||
* A typical <code>Page</code> may be created as follows:
|
|
||||||
* <blockquote><pre><code>
|
|
||||||
* Page p = new Page("Hello World");
|
* Page p = new Page("Hello World");
|
||||||
* p.add(new Label("Hello World");
|
* p.add(new Label("Hello World");
|
||||||
* p.lock();
|
* p.lock();
|
||||||
* </code></pre></blockquote>
|
* </code></pre></blockquote> </p>
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @author David Lutterkort
|
* @author David Lutterkort
|
||||||
* @author Stanislav Freidin
|
* @author Stanislav Freidin
|
||||||
* @author Uday Mathur
|
* @author Uday Mathur
|
||||||
*
|
*
|
||||||
* @version $Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $
|
* @version $Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $
|
||||||
*/
|
*/
|
||||||
public class Page extends BlockStylable implements Container {
|
public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
/** Class specific logger instance. */
|
/**
|
||||||
|
* Class specific logger instance.
|
||||||
|
*/
|
||||||
private static final Logger s_log = Logger.getLogger(Page.class);
|
private static final Logger s_log = Logger.getLogger(Page.class);
|
||||||
/** The delimiter character for components naming */
|
/**
|
||||||
|
* The delimiter character for components naming
|
||||||
|
*/
|
||||||
private static final String DELIMITER = ".";
|
private static final String DELIMITER = ".";
|
||||||
/**
|
/**
|
||||||
* The prefix that gets prepended to all state variables. Components must
|
* The prefix that gets prepended to all state variables. Components must
|
||||||
|
|
@ -95,8 +92,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
private static final String COMPONENT_PREFIX = "bbp" + DELIMITER;
|
private static final String COMPONENT_PREFIX = "bbp" + DELIMITER;
|
||||||
private static final String INTERNAL = COMPONENT_PREFIX;
|
private static final String INTERNAL = COMPONENT_PREFIX;
|
||||||
/**
|
/**
|
||||||
* The name of the special parameter that indicates which component has
|
* The name of the special parameter that indicates which component has been
|
||||||
* been selected.
|
* selected.
|
||||||
*/
|
*/
|
||||||
static final String SELECTED = INTERNAL + "s";
|
static final String SELECTED = INTERNAL + "s";
|
||||||
static final String CONTROL_EVENT = INTERNAL + "e";
|
static final String CONTROL_EVENT = INTERNAL + "e";
|
||||||
|
|
@ -117,10 +114,10 @@ public class Page extends BlockStylable implements Container {
|
||||||
*/
|
*/
|
||||||
static final String INVISIBLE = INTERNAL + "i";
|
static final String INVISIBLE = INTERNAL + "i";
|
||||||
/**
|
/**
|
||||||
* Map of stateful components (id --> Component)
|
* Map of stateful components (id --> Component) SortedMap used because
|
||||||
* SortedMap used because component based hash for page is based on concatenation of
|
* component based hash for page is based on concatenation of component ids,
|
||||||
* component ids, and so need to guarantee that they are returned in the same order
|
* and so need to guarantee that they are returned in the same order for the
|
||||||
* for the same page - cg.
|
* same page - cg.
|
||||||
*/
|
*/
|
||||||
private SortedMap m_componentMap;
|
private SortedMap m_componentMap;
|
||||||
private List m_components;
|
private List m_components;
|
||||||
|
|
@ -130,15 +127,16 @@ public class Page extends BlockStylable implements Container {
|
||||||
private Map m_componentParameterMap = new HashMap();
|
private Map m_componentParameterMap = new HashMap();
|
||||||
private FormModel m_stateModel;
|
private FormModel m_stateModel;
|
||||||
/**
|
/**
|
||||||
* <code>Container</code> that renders this <code>Page</code>.
|
* <code>Container</code> that renders this
|
||||||
|
* <code>Page</code>.
|
||||||
*/
|
*/
|
||||||
protected Container m_panel;
|
protected Container m_panel;
|
||||||
private List m_actionListeners;
|
private List m_actionListeners;
|
||||||
private List m_requestListeners;
|
private List m_requestListeners;
|
||||||
/**
|
/**
|
||||||
* The title of the page to be added in the head of HTML output. The
|
* The title of the page to be added in the head of HTML output. The title
|
||||||
* title is wrapped in a Label to allow developers to add
|
* is wrapped in a Label to allow developers to add PrintListeners to
|
||||||
* PrintListeners to dynamically change the value of the title.
|
* dynamically change the value of the title.
|
||||||
*/
|
*/
|
||||||
private Label m_title;
|
private Label m_title;
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,16 +145,16 @@ public class Page extends BlockStylable implements Container {
|
||||||
*/
|
*/
|
||||||
private RequestLocal m_currentTitle;
|
private RequestLocal m_currentTitle;
|
||||||
/**
|
/**
|
||||||
* A list of all the client-side stylesheets. The elements of the list
|
* A list of all the client-side stylesheets. The elements of the list are
|
||||||
* are of type Page.Stylesheet, defined at the end of this file.
|
* of type Page.Stylesheet, defined at the end of this file.
|
||||||
*/
|
*/
|
||||||
private List m_clientStylesheets;
|
private List m_clientStylesheets;
|
||||||
private StringParameter m_selected;
|
private StringParameter m_selected;
|
||||||
private StringParameter m_controlEvent;
|
private StringParameter m_controlEvent;
|
||||||
private StringParameter m_controlValue;
|
private StringParameter m_controlValue;
|
||||||
/**
|
/**
|
||||||
* The default (initial) visibility of components. The encoding is
|
* The default (initial) visibility of components. The encoding is identical
|
||||||
* identical to that for PageState.m_invisible.
|
* to that for PageState.m_invisible.
|
||||||
*
|
*
|
||||||
* This variable is package-friendly since it needs to be accessed by
|
* This variable is package-friendly since it needs to be accessed by
|
||||||
* PageState.
|
* PageState.
|
||||||
|
|
@ -172,51 +170,53 @@ public class Page extends BlockStylable implements Container {
|
||||||
*/
|
*/
|
||||||
private boolean m_finished = false;
|
private boolean m_finished = false;
|
||||||
/**
|
/**
|
||||||
* indicates whether pageState.stateAsURL() should export the
|
* indicates whether pageState.stateAsURL() should export the entire state
|
||||||
* entire state for this page, or whether it should only export
|
* for this page, or whether it should only export the control event as a
|
||||||
* the control event as a URL and use the HttpSession for the
|
* URL and use the HttpSession for the rest of the page state.
|
||||||
* rest of the page state.
|
|
||||||
*/
|
*/
|
||||||
private boolean m_useHttpSession = false;
|
private boolean m_useHttpSession = false;
|
||||||
|
/**
|
||||||
|
* HasMap for page generator information.
|
||||||
|
*/
|
||||||
|
private HashMap<String, String> m_pageGenerator = new HashMap<String, String>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> if this page should export state through
|
* Returns
|
||||||
* the HttpSession instead of the URL query string.
|
* <code>true</code> if this page should export state through the
|
||||||
* <P>If this returns <code>true</code>, then PageState.stateAsURL()
|
* HttpSession instead of the URL query string. <P>If this returns
|
||||||
* will only export the control event as
|
* <code>true</code>, then PageState.stateAsURL() will only export the
|
||||||
* a URL query string. If this returns <code>false</code>,
|
* control event as a URL query string. If this returns
|
||||||
* then stateAsURL() will export the entire page state.
|
* <code>false</code>, then stateAsURL() will export the entire page state.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @see PageState#stateAsURL
|
* @see PageState#stateAsURL
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if this page should export state through
|
* @return <code>true</code> if this page should export state through the
|
||||||
* the HttpSession; <code>false</code> if it should export using
|
* HttpSession; <code>false</code> if it should export using the URL query
|
||||||
* the URL query string.
|
* string.
|
||||||
*/
|
*/
|
||||||
public boolean isUsingHttpSession() {
|
public boolean isUsingHttpSession() {
|
||||||
return m_useHttpSession;
|
return m_useHttpSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates to this page whether it should export its entire state
|
* Indicates to this page whether it should export its entire state to
|
||||||
* to subsequent requests through the URL query string, or if it should
|
* subsequent requests through the URL query string, or if it should use the
|
||||||
* use the HttpSession instead and only use the URL query string for
|
* HttpSession instead and only use the URL query string for the control
|
||||||
* the control event.
|
* event.
|
||||||
*
|
*
|
||||||
* @see PageState#stateAsURL
|
* @see PageState#stateAsURL
|
||||||
*
|
*
|
||||||
* @param b <code>true</code> if PageState.stateAsURL()
|
* @param b <code>true</code> if PageState.stateAsURL() will export only the
|
||||||
* will export only the control event as a URL query string.
|
* control event as a URL query string. <code>false</code> if stateAsURL()
|
||||||
* <code>false</code> if stateAsURL() will export the entire page state.
|
* will export the entire page state.
|
||||||
*/
|
*/
|
||||||
public void setUsingHttpSession(boolean b) {
|
public void setUsingHttpSession(boolean b) {
|
||||||
m_useHttpSession = b;
|
m_useHttpSession = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty page with the specified title and
|
* Creates an empty page with the specified title and panel.
|
||||||
* panel.
|
|
||||||
*
|
*
|
||||||
* @param title title for this page
|
* @param title title for this page
|
||||||
*
|
*
|
||||||
|
|
@ -227,8 +227,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty page with the specified title and
|
* Creates an empty page with the specified title and panel.
|
||||||
* panel.
|
|
||||||
*
|
*
|
||||||
* @param title title for this page
|
* @param title title for this page
|
||||||
*
|
*
|
||||||
|
|
@ -248,7 +247,6 @@ public class Page extends BlockStylable implements Container {
|
||||||
// Initialize the RequestLocal where the title for the current
|
// Initialize the RequestLocal where the title for the current
|
||||||
// request will be kept
|
// request will be kept
|
||||||
m_currentTitle = new RequestLocal() {
|
m_currentTitle = new RequestLocal() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object initialValue(PageState state) {
|
protected Object initialValue(PageState state) {
|
||||||
return m_title.firePrintEvent(state);
|
return m_title.firePrintEvent(state);
|
||||||
|
|
@ -270,21 +268,20 @@ public class Page extends BlockStylable implements Container {
|
||||||
// Set up the visibility tracking parameters
|
// Set up the visibility tracking parameters
|
||||||
m_invisible = new BitSet(32);
|
m_invisible = new BitSet(32);
|
||||||
BitSetParameter p = new BitSetParameter(INVISIBLE,
|
BitSetParameter p = new BitSetParameter(INVISIBLE,
|
||||||
BitSetParameter.ENCODE_DGAP);
|
BitSetParameter.ENCODE_DGAP);
|
||||||
m_stateModel.addFormParam(p);
|
m_stateModel.addFormParam(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty page with default title and implicit BoxPanel
|
* Creates an empty page with default title and implicit BoxPanel container.
|
||||||
* container.
|
|
||||||
*/
|
*/
|
||||||
public Page() {
|
public Page() {
|
||||||
this("");
|
this("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty page with the specified title and implicit
|
* Creates an empty page with the specified title and implicit BoxPanel
|
||||||
* BoxPanel container.
|
* container.
|
||||||
*
|
*
|
||||||
* @param title title for this page
|
* @param title title for this page
|
||||||
*/
|
*/
|
||||||
|
|
@ -295,8 +292,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty page with the specified title and implicit
|
* Creates an empty page with the specified title and implicit BoxPanel
|
||||||
* BoxPanel container.
|
* container.
|
||||||
*
|
*
|
||||||
* @param title title for this page
|
* @param title title for this page
|
||||||
*/
|
*/
|
||||||
|
|
@ -315,31 +312,31 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a component with the specified layout constraints to this
|
* Adds a component with the specified layout constraints to this container.
|
||||||
* container. Layout constraints are defined in each layout container as
|
* Layout constraints are defined in each layout container as static ints.
|
||||||
* static ints. To specify multiple constraints, use bitwise OR.
|
* To specify multiple constraints, use bitwise OR.
|
||||||
*
|
*
|
||||||
* @param c component to add to this container
|
* @param c component to add to this container
|
||||||
*
|
*
|
||||||
* @param constraints layout constraints (a
|
* @param constraints layout constraints (a bitwise OR of static ints in the
|
||||||
* bitwise OR of static ints in the particular layout)
|
* particular layout)
|
||||||
*/
|
*/
|
||||||
public void add(Component c, int constraints) {
|
public void add(Component c, int constraints) {
|
||||||
m_panel.add(c, constraints);
|
m_panel.add(c, constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> if this list contains the specified element.
|
* Returns
|
||||||
* More formally, returns <code>true</code> if and only if this list
|
* <code>true</code> if this list contains the specified element. More
|
||||||
* contains at least
|
* formally, returns
|
||||||
* one element e such that (o==null ? e==null : o.equals(e)).
|
* <code>true</code> if and only if this list contains at least one element
|
||||||
* <P>
|
* e such that (o==null ? e==null : o.equals(e)). <P> This method returns
|
||||||
* This method returns <code>true</code> only if the component has been
|
* <code>true</code> only if the component has been directly added to this
|
||||||
* directly added to this container. If this container contains another
|
* container. If this container contains another container that contains
|
||||||
* container that contains this component, this method returns
|
* this component, this method returns
|
||||||
* <code>false</code>.
|
* <code>false</code>.
|
||||||
*
|
*
|
||||||
* @param o element whose presence in this container is to be tested
|
* @param o element whose presence in this container is to be tested
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if this Container contains the specified
|
* @return <code>true</code> if this Container contains the specified
|
||||||
* component directly; <code>false</code> otherwise.
|
* component directly; <code>false</code> otherwise.
|
||||||
|
|
@ -349,14 +346,12 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the
|
* Returns the component at the specified position. Each call to the add
|
||||||
* component at the specified position. Each call to the add method
|
* method increments the index. Since the user has no control over the index
|
||||||
* increments the index. Since the user has no control over the index
|
* of added components (other than counting each call to add), this method
|
||||||
* of added components (other than counting each call to add), this
|
* should be used in conjunction with indexOf.
|
||||||
* method should be used in conjunction with indexOf.
|
|
||||||
*
|
*
|
||||||
* @param index the index of the item to be retrieved from this
|
* @param index the index of the item to be retrieved from this Container
|
||||||
* Container
|
|
||||||
*
|
*
|
||||||
* @return the component at the specified position in this container.
|
* @return the component at the specified position in this container.
|
||||||
*/
|
*/
|
||||||
|
|
@ -365,25 +360,26 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the index of a
|
* Gets the index of a component.
|
||||||
* component.
|
|
||||||
*
|
*
|
||||||
* @param c component to search for
|
* @param c component to search for
|
||||||
*
|
*
|
||||||
* @return the index in this list of the first occurrence of the
|
* @return the index in this list of the first occurrence of the specified
|
||||||
* specified element, or -1 if this list does not contain this element.
|
* element, or -1 if this list does not contain this element.
|
||||||
*
|
*
|
||||||
* @pre c != null
|
* @pre c != null
|
||||||
* @post contains(c) implies (return >= 0) && (return < size())
|
* @post contains(c) implies (return >= 0) && (return < size())
|
||||||
* @post !contains(c) implies return == -1 */
|
* @post !contains(c) implies return == -1
|
||||||
|
*/
|
||||||
public int indexOf(Component c) {
|
public int indexOf(Component c) {
|
||||||
return m_panel.indexOf(c);
|
return m_panel.indexOf(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> if the container contains no components.
|
* Returns
|
||||||
|
* <code>true</code> if the container contains no components.
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if this container contains no
|
* @return <code>true</code> if this container contains no * *
|
||||||
* components; <code>false</code> otherwise.
|
* components; <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
|
|
@ -392,8 +388,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of elements in this container. This does not
|
* Returns the number of elements in this container. This does not
|
||||||
* recursively count the components that are indirectly contained
|
* recursively count the components that are indirectly contained in this
|
||||||
* in this container.
|
* container.
|
||||||
*
|
*
|
||||||
* @return the number of components directly in this container.
|
* @return the number of components directly in this container.
|
||||||
*/
|
*/
|
||||||
|
|
@ -407,8 +403,9 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the panel that the <code>Page</code> uses for rendering its
|
* Returns the panel that the
|
||||||
* components.
|
* <code>Page</code> uses for rendering its components.
|
||||||
|
*
|
||||||
* @return the panel.
|
* @return the panel.
|
||||||
*/
|
*/
|
||||||
public final Container getPanel() {
|
public final Container getPanel() {
|
||||||
|
|
@ -427,9 +424,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p> Retrieves the title of this page. </p>
|
||||||
* Retrieves the title of this page.
|
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @return the static title of this page.
|
* @return the static title of this page.
|
||||||
*/
|
*/
|
||||||
|
|
@ -468,16 +463,16 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link Component} that will display the validation errors
|
* Sets the {@link Component} that will display the validation errors in the
|
||||||
* in the current {@link PageState}. Any validation error in the
|
* current {@link PageState}. Any validation error in the
|
||||||
* <code>PageState</code> will cause the <code>Page</code> to completely
|
* <code>PageState</code> will cause the
|
||||||
* ignore all other components and render only the error display component.
|
* <code>Page</code> to completely ignore all other components and render
|
||||||
* <p>
|
* only the error display component. <p> By default, a
|
||||||
* By default, a {@link PageErrorDisplay} component is used to display the
|
* {@link PageErrorDisplay} component is used to display the validation
|
||||||
* validation errors.
|
* errors.
|
||||||
*
|
*
|
||||||
* @param c the component that will display the validation errors
|
* @param c the component that will display the validation errors in the
|
||||||
* in the current <code>PageState</code>
|
* current <code>PageState</code>
|
||||||
*/
|
*/
|
||||||
public final void setErrorDisplay(Component c) {
|
public final void setErrorDisplay(Component c) {
|
||||||
Assert.isUnlocked(this);
|
Assert.isUnlocked(this);
|
||||||
|
|
@ -485,29 +480,29 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link Component} that will display the validation errors
|
* Gets the {@link Component} that will display the validation errors in the
|
||||||
* in the current {@link PageState}. Any validation error in the
|
* current {@link PageState}. Any validation error in the
|
||||||
* <code>PageState</code> will cause the <code>Page</code> to completely
|
* <code>PageState</code> will cause the
|
||||||
* ignore all other components and render only the error display component.
|
* <code>Page</code> to completely ignore all other components and render
|
||||||
* <p>
|
* only the error display component. <p> By default, a
|
||||||
* By default, a {@link PageErrorDisplay} component is used to display the
|
* {@link PageErrorDisplay} component is used to display the validation
|
||||||
* validation errors.
|
* errors.
|
||||||
*
|
*
|
||||||
* @return the component that will display the validation errors
|
* @return the component that will display the validation errors in the
|
||||||
* in the current <code>PageState</code>.
|
* current <code>PageState</code>.
|
||||||
*/
|
*/
|
||||||
public final Component getErrorDisplay() {
|
public final Component getErrorDisplay() {
|
||||||
return m_errorDisplay;
|
return m_errorDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a client-side stylesheet that should be used in HTML
|
* Adds a client-side stylesheet that should be used in HTML output.
|
||||||
* output. Arbitrarily many client-side stylesheets can be added with
|
* Arbitrarily many client-side stylesheets can be added with this method.
|
||||||
* this method. To use a CSS stylesheet, call something like
|
* To use a CSS stylesheet, call something like
|
||||||
* <code>setStyleSheet("style.css", "text/css")</code>.
|
* <code>setStyleSheet("style.css", "text/css")</code>.
|
||||||
*
|
*
|
||||||
* <p> These values will ultimately wind up in a <tt><link></tt>
|
* <p> These values will ultimately wind up in a <tt><link></tt> tag
|
||||||
* tag in the head of the HTML page.
|
* in the head of the HTML page.
|
||||||
*
|
*
|
||||||
* <p> Note that the stylesheet set with this call has nothing to do with
|
* <p> Note that the stylesheet set with this call has nothing to do with
|
||||||
* the XSLT stylesheet (transformer) that is applied to the XML generated
|
* the XSLT stylesheet (transformer) that is applied to the XML generated
|
||||||
|
|
@ -515,7 +510,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
*
|
*
|
||||||
* @param styleSheetURI the location of the stylesheet
|
* @param styleSheetURI the location of the stylesheet
|
||||||
* @param mimeType the MIME type of the stylesheet, usually
|
* @param mimeType the MIME type of the stylesheet, usually
|
||||||
* <tt>text/css</tt>
|
* <tt>text/css</tt>
|
||||||
* @pre ! isLocked()
|
* @pre ! isLocked()
|
||||||
*/
|
*/
|
||||||
public void addClientStylesheet(String styleSheetURI, String mimeType) {
|
public void addClientStylesheet(String styleSheetURI, String mimeType) {
|
||||||
|
|
@ -523,14 +518,14 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a global state parameter to this page. Global parameters are
|
* Adds a global state parameter to this page. Global parameters are values
|
||||||
* values that need to be preserved between requests, but that have no
|
* that need to be preserved between requests, but that have no special
|
||||||
* special connection to any of the components on the page. For a page
|
* connection to any of the components on the page. For a page that displays
|
||||||
* that displays details about an item, a global parameter would be
|
* details about an item, a global parameter would be used to identify the
|
||||||
* used to identify the item.
|
* item.
|
||||||
*
|
*
|
||||||
* <p> If the parameter was previously added as a component state
|
* <p> If the parameter was previously added as a component state parameter,
|
||||||
* parameter, its name is unmangled and stays unmangled.
|
* its name is unmangled and stays unmangled.
|
||||||
*
|
*
|
||||||
* @param p the global parameter to add
|
* @param p the global parameter to add
|
||||||
*
|
*
|
||||||
|
|
@ -546,18 +541,17 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the top nodes of the DOM or JDOM tree. Used by
|
* Constructs the top nodes of the DOM or JDOM tree. Used by
|
||||||
* generateXML(PageState, Document) below.
|
* generateXML(PageState, Document) below. <p>Generates DOM fragment:
|
||||||
* <p>Generates DOM fragment:
|
|
||||||
* <pre>
|
* <pre>
|
||||||
* <bebop:page>
|
* <bebop:page>
|
||||||
* <bebop:title> ... value set with <i>setTitle</i> ... </bebop:title>
|
* <bebop:title> ... value set with <i>setTitle</i> ... </bebop:title>
|
||||||
* <bebop:stylesheet href='styleSheetURI' type='mimeType'>
|
* <bebop:stylesheet href='styleSheetURI' type='mimeType'>
|
||||||
* ... page content gnerated by children ...
|
* ... page content gnerated by children ...
|
||||||
* </bebop:page></pre>
|
* </bebop:page></pre> The content of the <tt><title></tt> element
|
||||||
* The content of the <tt><title></tt> element can be set by
|
* can be set by calling {@link #setTitle setTitle}. The
|
||||||
* calling {@link #setTitle setTitle}. The <tt><stylesheet></tt>
|
* <tt><stylesheet></tt> element will only be present if a stylesheet
|
||||||
* element will only be present if a stylesheet has been set with {@link
|
* has been set with {@link
|
||||||
* #setStyleSheet setStyleSheet}.
|
* #setStyleSheet setStyleSheet}.
|
||||||
*
|
*
|
||||||
* @param ps the page state for the current page
|
* @param ps the page state for the current page
|
||||||
|
|
@ -571,6 +565,9 @@ public class Page extends BlockStylable implements Container {
|
||||||
Element page = parent.createRootElement("bebop:page", BEBOP_XML_NS);
|
Element page = parent.createRootElement("bebop:page", BEBOP_XML_NS);
|
||||||
exportAttributes(page);
|
exportAttributes(page);
|
||||||
|
|
||||||
|
/* Generator information */
|
||||||
|
exportPageGenerator(page);
|
||||||
|
|
||||||
Element title = page.newChildElement("bebop:title", BEBOP_XML_NS);
|
Element title = page.newChildElement("bebop:title", BEBOP_XML_NS);
|
||||||
title.setText(getTitle(ps).getLabel(ps));
|
title.setText(getTitle(ps).getLabel(ps));
|
||||||
|
|
||||||
|
|
@ -582,10 +579,11 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a DOM or JDOM tree with all components on the page. The tree
|
* Constructs a DOM or JDOM tree with all components on the page. The tree
|
||||||
* represents the page that
|
* represents the page that results from the
|
||||||
* results from the {@link javax.servlet.http.HttpServletRequest} kept in
|
* {@link javax.servlet.http.HttpServletRequest} kept in the
|
||||||
* the <code>state</code>.
|
* <code>state</code>.
|
||||||
|
*
|
||||||
* @param state the page state produced by {@link #process}
|
* @param state the page state produced by {@link #process}
|
||||||
* @param parent the DOM node for the whole Document
|
* @param parent the DOM node for the whole Document
|
||||||
* @see #process process
|
* @see #process process
|
||||||
|
|
@ -623,19 +621,18 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do nothing. Top-level add nodes is meaningless.
|
* Do nothing. Top-level add nodes is meaningless.
|
||||||
*/
|
*/
|
||||||
public void generateXML(PageState state, Element elt) {
|
public void generateXML(PageState state, Element elt) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PageState object and processes it by calling the
|
* Creates a PageState object and processes it by calling the respond method
|
||||||
* respond method on the
|
* on the selected component. Processes a request by notifying the component
|
||||||
* selected component. Processes a request by notifying the component
|
|
||||||
* from which the process originated and {@link #fireActionEvent
|
* from which the process originated and {@link #fireActionEvent
|
||||||
* broadcasts} an {@link ActionEvent} to all the listeners that
|
* broadcasts} an {@link ActionEvent} to all the listeners that registered
|
||||||
* registered with {@link #addActionListener addActionListener}.
|
* with {@link #addActionListener addActionListener}.
|
||||||
*
|
*
|
||||||
* @see #generateXML(PageState,Document) generateXML
|
* @see #generateXML(PageState,Document) generateXML
|
||||||
* @pre isLocked()
|
* @pre isLocked()
|
||||||
|
|
@ -643,7 +640,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
* @pre response != null
|
* @pre response != null
|
||||||
*/
|
*/
|
||||||
public PageState process(HttpServletRequest request,
|
public PageState process(HttpServletRequest request,
|
||||||
HttpServletResponse response)
|
HttpServletResponse response)
|
||||||
throws ServletException {
|
throws ServletException {
|
||||||
|
|
||||||
PageState result = new PageState(this, request, response);
|
PageState result = new PageState(this, request, response);
|
||||||
|
|
@ -657,9 +654,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the supplied PageState object according to this
|
* Processes the supplied PageState object according to this PageModel.
|
||||||
* PageModel. Calls the respond method on the selected Bebop
|
* Calls the respond method on the selected Bebop component.
|
||||||
* component.
|
|
||||||
*/
|
*/
|
||||||
public void process(PageState state) throws ServletException {
|
public void process(PageState state) throws ServletException {
|
||||||
Assert.isLocked(this);
|
Assert.isLocked(this);
|
||||||
|
|
@ -704,18 +700,17 @@ public class Page extends BlockStylable implements Container {
|
||||||
// return state;
|
// return state;
|
||||||
// }
|
// }
|
||||||
/**
|
/**
|
||||||
* Builds a DOM Document from the current request state by
|
* Builds a DOM Document from the current request state by doing a
|
||||||
* doing a depth-first tree walk on the current set of components
|
* depth-first tree walk on the current set of components in this Page,
|
||||||
* in this Page, calling generateXML on each. Does NOT do the rendering.
|
* calling generateXML on each. Does NOT do the rendering. If the HTTP
|
||||||
* If the HTTP response has already been committed, does not
|
* response has already been committed, does not build the XML document.
|
||||||
* build the XML document.
|
|
||||||
*
|
*
|
||||||
* @return a DOM ready for rendering, or null if the response has
|
* @return a DOM ready for rendering, or null if the response has already
|
||||||
* already been committed.
|
* been committed.
|
||||||
* @post res.isCommitted() == (return == null)
|
* @post res.isCommitted() == (return == null)
|
||||||
*/
|
*/
|
||||||
public Document buildDocument(HttpServletRequest req,
|
public Document buildDocument(HttpServletRequest req,
|
||||||
HttpServletResponse res)
|
HttpServletResponse res)
|
||||||
throws ServletException {
|
throws ServletException {
|
||||||
try {
|
try {
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
|
|
@ -743,8 +738,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finishes building the page. The tree of components is traversed and each
|
* Finishes building the page. The tree of components is traversed and each
|
||||||
* component is told to add its state parameters to the page's state
|
* component is told to add its state parameters to the page's state model.
|
||||||
* model.
|
|
||||||
*
|
*
|
||||||
* @pre ! isLocked()
|
* @pre ! isLocked()
|
||||||
*/
|
*/
|
||||||
|
|
@ -753,7 +747,6 @@ public class Page extends BlockStylable implements Container {
|
||||||
Assert.isUnlocked(this);
|
Assert.isUnlocked(this);
|
||||||
|
|
||||||
Traversal componentRegistrar = new Traversal() {
|
Traversal componentRegistrar = new Traversal() {
|
||||||
|
|
||||||
protected void act(Component c) {
|
protected void act(Component c) {
|
||||||
addComponent(c);
|
addComponent(c);
|
||||||
c.register(Page.this);
|
c.register(Page.this);
|
||||||
|
|
@ -784,7 +777,6 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
m_stateModel.lock();
|
m_stateModel.lock();
|
||||||
Traversal componentLocker = new Traversal() {
|
Traversal componentLocker = new Traversal() {
|
||||||
|
|
||||||
protected void act(Component c) {
|
protected void act(Component c) {
|
||||||
c.lock();
|
c.lock();
|
||||||
}
|
}
|
||||||
|
|
@ -800,8 +792,9 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a listener that is notified whenever a request to this page
|
* Registers a listener that is notified whenever a request to this page is
|
||||||
* is made, after the selected component has had a chance to respond.
|
* made, after the selected component has had a chance to respond.
|
||||||
|
*
|
||||||
* @pre l != null
|
* @pre l != null
|
||||||
* @pre ! isLocked()
|
* @pre ! isLocked()
|
||||||
*/
|
*/
|
||||||
|
|
@ -812,6 +805,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a previously registered action listener.
|
* Remove a previously registered action listener.
|
||||||
|
*
|
||||||
* @pre l != null
|
* @pre l != null
|
||||||
* @pre ! isLocked()
|
* @pre ! isLocked()
|
||||||
*/
|
*/
|
||||||
|
|
@ -821,8 +815,9 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a listener that is notified whenever a request to this page
|
* Registers a listener that is notified whenever a request to this page is
|
||||||
* is made, before the selected component has had a chance to respond.
|
* made, before the selected component has had a chance to respond.
|
||||||
|
*
|
||||||
* @pre l != null
|
* @pre l != null
|
||||||
* @pre ! isLocked()
|
* @pre ! isLocked()
|
||||||
*/
|
*/
|
||||||
|
|
@ -833,6 +828,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a previously registered request listener.
|
* Removes a previously registered request listener.
|
||||||
|
*
|
||||||
* @param 1 the listener to remove
|
* @param 1 the listener to remove
|
||||||
* @pre l != null
|
* @pre l != null
|
||||||
* @pre ! isLocked()
|
* @pre ! isLocked()
|
||||||
|
|
@ -843,9 +839,10 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts an {@link ActionEvent} to all registered listeners. The
|
* Broadcasts an {@link ActionEvent} to all registered listeners. The source
|
||||||
* source of the event is this page, and the state recorded in the event
|
* of the event is this page, and the state recorded in the event is the one
|
||||||
* is the one resulting from processing the current request.
|
* resulting from processing the current request.
|
||||||
|
*
|
||||||
* @param the state for this event
|
* @param the state for this event
|
||||||
*
|
*
|
||||||
* @pre state != null
|
* @pre state != null
|
||||||
|
|
@ -869,10 +866,11 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a {@link RequestEvent} to all registered listeners. The
|
* Broadcasts a {@link RequestEvent} to all registered listeners. The source
|
||||||
* source of the event is this page, and the state recorded in the event
|
* of the event is this page, and the state recorded in the event is the one
|
||||||
* is the one resulting from processing the current request.
|
* resulting from processing the current request.
|
||||||
* @param the state for this event
|
*
|
||||||
|
* @param state the state for this event
|
||||||
*
|
*
|
||||||
* @pre state != null
|
* @pre state != null
|
||||||
*/
|
*/
|
||||||
|
|
@ -894,6 +892,49 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected void addPageGeneratorInformation(String key, String value) {
|
||||||
|
if (key != null && !key.isEmpty()) {
|
||||||
|
m_pageGenerator.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected String getPageGeneratorInformation(String key) {
|
||||||
|
if (key != null && !key.isEmpty()) {
|
||||||
|
return m_pageGenerator.get(key);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected String removePageGeneratorInformation(String key) {
|
||||||
|
if (key != null && !key.isEmpty()) {
|
||||||
|
return m_pageGenerator.remove(key);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export page generator information if set. The m_pageGenerator is a
|
||||||
|
* HashMap containing the information as key value. In general this should
|
||||||
|
* include generator name and generator version.
|
||||||
|
*
|
||||||
|
* @param page parent element - should be bebeop:page
|
||||||
|
*
|
||||||
|
* @pre m_pageGenerator != null && !m_pageGenerator.isEmpty()
|
||||||
|
*/
|
||||||
|
final protected void exportPageGenerator(Element page) {
|
||||||
|
if (m_pageGenerator != null && !m_pageGenerator.isEmpty()) {
|
||||||
|
Element gen = page.newChildElement("bebop:pageGenerator", BEBOP_XML_NS);
|
||||||
|
|
||||||
|
Iterator<Map.Entry<String, String>> keyValues = ((Set<Map.Entry<String, String>>) m_pageGenerator.entrySet()).iterator();
|
||||||
|
while (keyValues.hasNext()) {
|
||||||
|
Map.Entry<String, String> entry = keyValues.next();
|
||||||
|
gen.addAttribute(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Client-side stylesheet storage
|
// Client-side stylesheet storage
|
||||||
private class Stylesheet {
|
private class Stylesheet {
|
||||||
|
|
||||||
|
|
@ -907,7 +948,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
public void generateXML(Element parent) {
|
public void generateXML(Element parent) {
|
||||||
Element style = parent.newChildElement("bebop:stylesheet",
|
Element style = parent.newChildElement("bebop:stylesheet",
|
||||||
BEBOP_XML_NS);
|
BEBOP_XML_NS);
|
||||||
style.addAttribute("href", m_URI);
|
style.addAttribute("href", m_URI);
|
||||||
if (m_type != null) {
|
if (m_type != null) {
|
||||||
style.addAttribute("type", m_type);
|
style.addAttribute("type", m_type);
|
||||||
|
|
@ -927,8 +968,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
s_log.error("c is null");
|
s_log.error("c is null");
|
||||||
} /*else {
|
} /*else {
|
||||||
s_log.error("c: " + c.toString());
|
s_log.error("c: " + c.toString());
|
||||||
}*/
|
}*/
|
||||||
String key = c.getKey();
|
String key = c.getKey();
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
key = Integer.toString(m_components.size());
|
key = Integer.toString(m_components.size());
|
||||||
|
|
@ -946,10 +987,10 @@ public class Page extends BlockStylable implements Container {
|
||||||
/**
|
/**
|
||||||
* Registers a state parameter for a component. It is permissible to
|
* Registers a state parameter for a component. It is permissible to
|
||||||
* register the same state parameter several times, from the same or
|
* register the same state parameter several times, from the same or
|
||||||
* different components. The name of the parameter will be changed
|
* different components. The name of the parameter will be changed to ensure
|
||||||
* to ensure that it won't clash with any other component's parameter.
|
* that it won't clash with any other component's parameter. If the
|
||||||
* If the parameter is added more than once, the name is only changed
|
* parameter is added more than once, the name is only changed the first
|
||||||
* the first time it is added.
|
* time it is added.
|
||||||
*
|
*
|
||||||
* @param c the component to register the parameter for
|
* @param c the component to register the parameter for
|
||||||
* @param p the state parameter to register
|
* @param p the state parameter to register
|
||||||
|
|
@ -970,7 +1011,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
if (!m_stateModel.containsFormParam(p)) {
|
if (!m_stateModel.containsFormParam(p)) {
|
||||||
String name = parameterName(c, p.getName());
|
String name = parameterName(c, p.getName());
|
||||||
s_log.debug(String.format("Setting name of parameter to add to '%s'",
|
s_log.debug(String.format("Setting name of parameter to add to '%s'",
|
||||||
name));
|
name));
|
||||||
p.setName(name);
|
p.setName(name);
|
||||||
m_stateModel.addFormParam(p);
|
m_stateModel.addFormParam(p);
|
||||||
|
|
||||||
|
|
@ -991,13 +1032,13 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the state index of a component. This is the number assigned
|
* Gets the state index of a component. This is the number assigned to the
|
||||||
* to the component in the register traveral
|
* component in the register traveral
|
||||||
*
|
*
|
||||||
* @param c the component to search for
|
* @param c the component to search for
|
||||||
*
|
*
|
||||||
* @return the index in this list of the first occurrence of the
|
* @return the index in this list of the first occurrence of the specified
|
||||||
* specified element, or -1 if this list does not contain this element.
|
* element, or -1 if this list does not contain this element.
|
||||||
*
|
*
|
||||||
* @pre c != null
|
* @pre c != null
|
||||||
* @post contains(c) implies (return >= 0) && (return < size())
|
* @post contains(c) implies (return >= 0) && (return < size())
|
||||||
|
|
@ -1045,8 +1086,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the form model that contains the parameters for the page's
|
* Gets the form model that contains the parameters for the page's state.
|
||||||
* state.
|
|
||||||
*/
|
*/
|
||||||
public final FormModel getStateModel() {
|
public final FormModel getStateModel() {
|
||||||
return m_stateModel;
|
return m_stateModel;
|
||||||
|
|
@ -1062,14 +1102,13 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the specified component is visible by default on
|
* Checks whether the specified component is visible by default on the page.
|
||||||
* the page.
|
|
||||||
*
|
*
|
||||||
* @param c a component contained in the page
|
* @param c a component contained in the page
|
||||||
* @return <code>true</code> if the component is visible by default;
|
* @return <code>true</code> if the component is visible by default;
|
||||||
* <code>false</code> otherwise.
|
* <code>false</code> otherwise.
|
||||||
* @see #setVisibleDefault setVisibleDefault
|
* @see #setVisibleDefault setVisibleDefault
|
||||||
* @see Component#setVisible Component.setVisible
|
* @see Component#setVisible Component.setVisible
|
||||||
*/
|
*/
|
||||||
public boolean isVisibleDefault(Component c) {
|
public boolean isVisibleDefault(Component c) {
|
||||||
Assert.isTrue(stateContains(c));
|
Assert.isTrue(stateContains(c));
|
||||||
|
|
@ -1078,10 +1117,10 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the specified component is visible by default. The
|
* Sets whether the specified component is visible by default. The default
|
||||||
* default visibility is used when a page is displayed for the first
|
* visibility is used when a page is displayed for the first time and on
|
||||||
* time and on subsequent requests until the visibility of a component
|
* subsequent requests until the visibility of a component is changed
|
||||||
* is changed explicitly with {@link Component#setVisible
|
* explicitly with {@link Component#setVisible
|
||||||
* Component.setVisible}.
|
* Component.setVisible}.
|
||||||
*
|
*
|
||||||
* <p> When a component is first added to a page, it is visible.
|
* <p> When a component is first added to a page, it is visible.
|
||||||
|
|
@ -1089,7 +1128,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
* @param c a component whose visibility is to be set
|
* @param c a component whose visibility is to be set
|
||||||
* @param v <code>true</code> if the component is visible;
|
* @param v <code>true</code> if the component is visible;
|
||||||
* <code>false</code> otherwise.
|
* <code>false</code> otherwise.
|
||||||
* @see Component#setVisible Component.setVisible
|
* @see Component#setVisible Component.setVisible
|
||||||
* @see Component#register Component.register
|
* @see Component#register Component.register
|
||||||
*/
|
*/
|
||||||
public void setVisibleDefault(Component c, boolean v) {
|
public void setVisibleDefault(Component c, boolean v) {
|
||||||
|
|
@ -1105,7 +1144,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The global name of the parameter <code>name</code> in the component
|
* The global name of the parameter
|
||||||
|
* <code>name</code> in the component
|
||||||
* <code>c</code>.
|
* <code>c</code>.
|
||||||
*/
|
*/
|
||||||
public String parameterName(Component c, String name) {
|
public String parameterName(Component c, String name) {
|
||||||
|
|
@ -1117,7 +1157,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The global name of the parameter <code>name</code>.
|
* The global name of the parameter
|
||||||
|
* <code>name</code>.
|
||||||
*/
|
*/
|
||||||
public String parameterName(String name) {
|
public String parameterName(String name) {
|
||||||
return parameterName(null, name);
|
return parameterName(null, name);
|
||||||
|
|
@ -1125,7 +1166,6 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
void reset(final PageState ps, Component cmpnt) {
|
void reset(final PageState ps, Component cmpnt) {
|
||||||
Traversal resetter = new Traversal() {
|
Traversal resetter = new Traversal() {
|
||||||
|
|
||||||
protected void act(Component c) {
|
protected void act(Component c) {
|
||||||
Collection cp = getComponentParameters(c);
|
Collection cp = getComponentParameters(c);
|
||||||
if (cp != null) {
|
if (cp != null) {
|
||||||
|
|
@ -1142,8 +1182,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the prefix that is prepended to each component's state
|
* Return the prefix that is prepended to each component's state parameters
|
||||||
* parameters to keep them unique.
|
* to keep them unique.
|
||||||
*/
|
*/
|
||||||
private final String componentPrefix(Component c) {
|
private final String componentPrefix(Component c) {
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
|
|
@ -1186,7 +1226,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
private static String NAME = "name";
|
private static String NAME = "name";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Produces an XML fragment that captures the layout of this page.
|
* Produces an XML fragment that captures the layout of this page.
|
||||||
*/
|
*/
|
||||||
private void showStructure(PageState s, Element root) {
|
private void showStructure(PageState s, Element root) {
|
||||||
final HttpServletRequest req = s.getRequest();
|
final HttpServletRequest req = s.getRequest();
|
||||||
|
|
@ -1248,7 +1288,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
parent.newChildElement("bebop:param", BEBOP_XML_NS);
|
parent.newChildElement("bebop:param", BEBOP_XML_NS);
|
||||||
param.addAttribute(NAME, unmangle(p.getName()));
|
param.addAttribute(NAME, unmangle(p.getName()));
|
||||||
param.addAttribute("defaultValue",
|
param.addAttribute("defaultValue",
|
||||||
String.valueOf(req.getParameter(p.getName())));
|
String.valueOf(req.getParameter(p.getName())));
|
||||||
param.addAttribute("currentValue", String.valueOf(s.getValue(p)));
|
param.addAttribute("currentValue", String.valueOf(s.getValue(p)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1267,21 +1307,21 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return a string that represents an ordered list of component
|
* return a string that represents an ordered list of component ids used on
|
||||||
* ids used on the page. For situations where only the
|
* the page. For situations where only the components present is of
|
||||||
* components present is of importance, this may be used
|
* importance, this may be used by implementations of hashCode & equals
|
||||||
* by implementations of hashCode & equals
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getComponentString() {
|
public String getComponentString() {
|
||||||
Iterator it = m_componentMap.keySet().iterator();
|
Iterator it = m_componentMap.keySet().iterator();
|
||||||
/*int hash = 0;
|
/*int hash = 0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
String componentId = (String)it.next();
|
String componentId = (String)it.next();
|
||||||
s_log.debug("component id = " + componentId);
|
s_log.debug("component id = " + componentId);
|
||||||
hash = hash | componentId.hashCode();
|
hash = hash | componentId.hashCode();
|
||||||
s_log.debug("hash so far = " + hash);
|
s_log.debug("hash so far = " + hash);
|
||||||
}*/
|
}*/
|
||||||
Date start = new Date();
|
Date start = new Date();
|
||||||
|
|
||||||
StringBuffer hashString = new StringBuffer();
|
StringBuffer hashString = new StringBuffer();
|
||||||
|
|
@ -1290,7 +1330,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
hashString.append(componentId);
|
hashString.append(componentId);
|
||||||
}
|
}
|
||||||
s_log.debug("Time to create hashCode for page: " + (new Date().getTime() - start.
|
s_log.debug("Time to create hashCode for page: " + (new Date().getTime() - start.
|
||||||
getTime()));
|
getTime()));
|
||||||
return hashString.toString();
|
return hashString.toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue