You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/05/03 15:15:30 UTC
svn commit: r534844 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/ajax/api/
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/renderkit/
core/src/main/java/org/apache/myfaces...
Author: bommel
Date: Thu May 3 06:15:29 2007
New Revision: 534844
URL: http://svn.apache.org/viewvc?view=rev&rev=534844
Log:
(TOBAGO-379) Caching UIPage in ComponentUtil.findPage in the RequestMap
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIFileInput.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SheetUtils.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/InRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java Thu May 3 06:15:29 2007
@@ -159,7 +159,7 @@
ExternalContext externalContext = facesContext.getExternalContext();
RequestUtils.ensureEncoding(externalContext);
ResponseUtils.ensureNoCacheHeader(externalContext);
- UIComponent page = ComponentUtil.findPage(AjaxUtils.getAjaxComponents(facesContext).get(0));
+ UIComponent page = ComponentUtil.findPage(facesContext, AjaxUtils.getAjaxComponents(facesContext).get(0));
String charset = (String) page.getAttributes().get(ATTR_CHARSET);
ResponseUtils.ensureContentTypeHeader(facesContext, charset);
StringBuilder buffer = new StringBuilder(responseCode);
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIFileInput.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIFileInput.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIFileInput.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIFileInput.java Thu May 3 06:15:29 2007
@@ -36,7 +36,7 @@
public void setParent(UIComponent uiComponent) {
super.setParent(uiComponent);
- UIPage form = ComponentUtil.findPage(uiComponent);
+ UIPage form = ComponentUtil.findPage(getFacesContext(), uiComponent);
if (form != null) {
form.getAttributes().put(ATTR_ENCTYPE, "multipart/form-data");
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java Thu May 3 06:15:29 2007
@@ -77,13 +77,13 @@
}
private boolean isSubmitted() {
- String action = ComponentUtil.findPage(this).getActionId();
- return action != null && action.startsWith(getClientId(FacesContext.getCurrentInstance()) + SEPARATOR_CHAR);
+ String action = ComponentUtil.findPage(getFacesContext(), this).getActionId();
+ return action != null && action.startsWith(getClientId(getFacesContext()) + SEPARATOR_CHAR);
}
private boolean isRedisplay() {
if (isSubmitted()) {
- UIPage page = ComponentUtil.findPage(this);
+ UIPage page = ComponentUtil.findPage(getFacesContext(), this);
String action = page.getActionId();
if (action != null) {
UIComponent command = page.findComponent(SEPARATOR_CHAR + action);
@@ -236,7 +236,7 @@
}
private void addToPage() {
- UIPage page = ComponentUtil.findPage(this);
+ UIPage page = ComponentUtil.findPage(getFacesContext(), this);
if (page != null) {
page.getPopups().add(this);
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java Thu May 3 06:15:29 2007
@@ -25,7 +25,7 @@
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
-public abstract class CommandRendererBase extends RendererBase {
+public abstract class CommandRendererBase extends LayoutableRendererBase {
private static final Log LOG = LogFactory.getLog(CommandRendererBase.class);
@@ -34,7 +34,7 @@
if (ComponentUtil.isOutputOnly(component)) {
return;
}
- String actionId = ComponentUtil.findPage(component).getActionId();
+ String actionId = ComponentUtil.findPage(facesContext, component).getActionId();
String clientId = component.getClientId(facesContext);
if (LOG.isDebugEnabled()) {
LOG.debug("actionId = '" + actionId + "'");
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SheetUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SheetUtils.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SheetUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SheetUtils.java Thu May 3 06:15:29 2007
@@ -41,7 +41,7 @@
public class SheetUtils {
private static final Log LOG = LogFactory.getLog(SheetUtils.class);
public static void decode(FacesContext facesContext, UIComponent component) {
- String actionId = ComponentUtil.findPage(component).getActionId();
+ String actionId = ComponentUtil.findPage(facesContext, component).getActionId();
String clientId = component.getClientId(facesContext);
if (LOG.isDebugEnabled()) {
LOG.debug("actionId = '" + actionId + "'");
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java Thu May 3 06:15:29 2007
@@ -117,7 +117,7 @@
}
} else if (defaultCommand) {
- ComponentUtil.findPage(command).setDefaultActionId(clientId);
+ ComponentUtil.findPage(facesContext, command).setDefaultActionId(clientId);
onclick = null;
} else {
String target = ComponentUtil.getStringAttribute(command, ATTR_TARGET);
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java Thu May 3 06:15:29 2007
@@ -70,7 +70,7 @@
throws IOException {
if (ComponentUtil.getBooleanAttribute(component, ATTR_FOCUS)) {
- UIPage page = ComponentUtil.findPage(component);
+ UIPage page = ComponentUtil.findPage(facesContext, component);
String id = component.getClientId(facesContext);
if (!StringUtils.isBlank(page.getFocusId()) && !page.getFocusId().equals(id)) {
LOG.warn("page focusId = \"" + page.getFocusId() + "\" ignoring new value \""
Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java Thu May 3 06:15:29 2007
@@ -158,7 +158,7 @@
String[] scriptTexts = createJavascript(facesContext, clientId, root);
String[] scripts = {"script/tobago-tree.js"};
- List<String> scriptFiles = ComponentUtil.findPage(tree).getScriptFiles();
+ List<String> scriptFiles = ComponentUtil.findPage(facesContext, tree).getScriptFiles();
for (String script : scripts) {
scriptFiles.add(script);
}
Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/InRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/InRenderer.java Thu May 3 06:15:29 2007
@@ -45,7 +45,7 @@
String clientId = component.getClientId(facesContext);
- UIPage uiPage = ComponentUtil.findPage(component);
+ UIPage uiPage = ComponentUtil.findPage(facesContext, component);
if (uiPage != null){
uiPage.getPostfields().add(new DefaultKeyValue(clientId, clientId));
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java Thu May 3 06:15:29 2007
@@ -118,7 +118,7 @@
UIComponent image = (UIComponent) link.getChildren().get(1);
image.setId(idPrefix + "image");
if (popup != null) {
- UIPage page = ComponentUtil.findPage(link);
+ UIPage page = ComponentUtil.findPage(facesContext, link);
page.getPopups().add(popup);
}
if (!ComponentUtil.containsPopupActionListener(link)) {
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java Thu May 3 06:15:29 2007
@@ -50,7 +50,7 @@
"script/calendar.js"};
final List<String> scriptFiles
- = ComponentUtil.findPage(component).getScriptFiles();
+ = ComponentUtil.findPage(facesContext, component).getScriptFiles();
for (String script : scripts) {
scriptFiles.add(script);
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java Thu May 3 06:15:29 2007
@@ -34,7 +34,7 @@
public void decode(FacesContext facesContext, UIComponent component) {
UIForm form = (UIForm) component;
- UIPage page = ComponentUtil.findPage(form);
+ UIPage page = ComponentUtil.findPage(facesContext, form);
String actionId = page.getActionId();
String clientId = form.getClientId(facesContext);
if (actionId != null && actionId.startsWith(clientId)) {
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java Thu May 3 06:15:29 2007
@@ -41,6 +41,13 @@
import org.apache.myfaces.tobago.component.UIGridLayout;
import org.apache.myfaces.tobago.component.UILayout;
import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.component.LayoutTokens;
+import org.apache.myfaces.tobago.component.RelativeLayoutToken;
+import org.apache.myfaces.tobago.component.LayoutToken;
+import org.apache.myfaces.tobago.component.PixelLayoutToken;
+import org.apache.myfaces.tobago.component.MinimumLayoutToken;
+import org.apache.myfaces.tobago.component.FixedLayoutToken;
+import org.apache.myfaces.tobago.component.HideLayoutToken;
import org.apache.myfaces.tobago.renderkit.RenderUtil;
import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
@@ -83,28 +90,29 @@
return width;
}
- public int calculateLayoutHeight(
+ private int calculateLayoutHeight(
FacesContext facesContext, UIComponent component, boolean minimum) {
UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
final List<UIGridLayout.Row> rows = layout.ensureRows();
- String rowLayout
- = (String) layout.getAttributes().get(ATTR_ROWS);
- if (rowLayout == null && !minimum && LOG.isDebugEnabled()) {
+ LayoutTokens layoutTokens = layout.getRowLayout();
+
+ if (layoutTokens == null && !minimum && LOG.isDebugEnabled()) {
LOG.debug("No rowLayout found using " + (minimum ? "'minimum'" : "'fixed'")
+ " for all " + rows.size() + " rows of "
+ layout.getClientId(facesContext) + " !");
}
- String[] layoutTokens
- = LayoutInfo.createLayoutTokens(rowLayout, rows.size(),
- minimum ? "minimum" : "fixed");
+ layoutTokens.ensureSize(rows.size(), new RelativeLayoutToken(1));//new FixedLayoutToken() );
+ //String[] layoutTokens
+ // = LayoutInfo.createLayoutTokens(rowLayout, rows.size(),
+ // minimum ? "minimum" : "fixed");
- if (rows.size() != layoutTokens.length) {
+ if (rows.size() != layoutTokens.getSize()) {
LOG.warn("Unbalanced layout: rows.size()=" + rows.size()
- + " != layoutTokens.length=" + layoutTokens.length
- + " rowLayout='" + rowLayout + "'");
+ + " != layoutTokens.length=" + layoutTokens.getSize()
+ + " rowLayout='" + layoutTokens + "'");
}
- int size = Math.min(rows.size(), layoutTokens.length);
+ int size = Math.min(rows.size(), layoutTokens.getSize());
int height = 0;
height += getMarginAsInt(layout.getMarginTop());
@@ -114,19 +122,19 @@
continue;
}
height += getCellPadding(facesContext, layout, i);
- String token = layoutTokens[i];
- if (token.matches("\\d+px")) {
- height += Integer.parseInt(token.replaceAll("\\D", ""));
- } else if (token.equals("fixed")) {
+ LayoutToken token = layoutTokens.get(i);
+ if (token instanceof PixelLayoutToken) {
+ height += ((PixelLayoutToken) token).getPixel();
+ } else if (token instanceof FixedLayoutToken) {
height += getMaxHeight(facesContext, rows.get(i), false);
- } else if (token.equals("minimum")) {
+ } else if (token instanceof MinimumLayoutToken) {
height += getMaxHeight(facesContext, rows.get(i), true);
} else {
if (!minimum && LOG.isWarnEnabled()) {
LOG.warn("Unable to calculate Height for token '" + token
+ "'! using " + (minimum ? "'minimum'" : "'fixed'") + " , component:"
- + layout.getClientId(facesContext) + " is "
- + layout.getRendererType());
+ + component.getClientId(facesContext) + " is "
+ + component.getRendererType());
}
height += getMaxHeight(facesContext, rows.get(i), minimum);
}
@@ -142,24 +150,24 @@
final List<UIGridLayout.Row> rows = layout.ensureRows();
UIGridLayout.Row row = rows.get(0);
- String columnLayout
- = (String) layout.getAttributes().get(ATTR_COLUMNS);
- if (columnLayout == null && !minimum && LOG.isDebugEnabled()) {
+ LayoutTokens layoutTokens = layout.getColumnLayout();
+
+ if (layoutTokens == null && !minimum && LOG.isDebugEnabled()) {
LOG.debug("No rowLayout found using " + (minimum ? "'minimum'" : "'fixed'")
+ " for all " + rows.size() + " rows of "
+ layout.getClientId(facesContext) + " !");
}
- String[] layoutTokens
- = LayoutInfo.createLayoutTokens(columnLayout, row.getColumns(),
- minimum ? "minimum" : "fixed");
+ //String[] layoutTokens
+ // = LayoutInfo.createLayoutTokens(columnLayout, row.getColumns(),
+ layoutTokens.ensureSize(row.getColumns(), new FixedLayoutToken());
- if (row.getColumns() != layoutTokens.length) {
+ if (row.getColumns() != layoutTokens.getSize()) {
LOG.warn("Unbalanced layout: rows.size()=" + rows.size()
- + " != layoutTokens.length=" + layoutTokens.length
- + " columnLayout='" + columnLayout + "'");
+ + " != layoutTokens.length=" + layoutTokens.getSize()
+ + " columnLayout='" + layoutTokens + "'");
}
- int size = Math.min(rows.size(), layoutTokens.length);
+ int size = Math.min(rows.size(), layoutTokens.getSize());
int width = 0;
width += getMarginAsInt(layout.getMarginLeft());
@@ -169,19 +177,19 @@
continue;
}
width += getCellPadding(facesContext, layout, i);
- String token = layoutTokens[i];
- if (token.matches("\\d+px")) {
- width += Integer.parseInt(token.replaceAll("\\D", ""));
- } else if (token.equals("fixed")) {
+ LayoutToken token = layoutTokens.get(i);
+ if (token instanceof PixelLayoutToken) {
+ width += ((PixelLayoutToken) token).getPixel();
+ } else if (token instanceof FixedLayoutToken) {
width += getMaxWidth(facesContext, rows, i, false);
- } else if (token.equals("minimum")) {
+ } else if (token instanceof MinimumLayoutToken) {
width += getMaxWidth(facesContext, rows, i, true);
} else {
if (!minimum && LOG.isWarnEnabled()) {
LOG.warn("Unable to calculate Width for token '" + token
+ "'! using " + (minimum ? "'minimum'" : "'fixed'") + " , component:"
- + layout.getClientId(facesContext) + " is "
- + layout.getRendererType());
+ + component.getClientId(facesContext) + " is "
+ + component.getRendererType());
}
width += getMaxWidth(facesContext, rows, i, minimum);
}
@@ -504,9 +512,11 @@
final List<UIGridLayout.Row> rows = layout.ensureRows();
final int columnCount = layout.getColumnCount();
- final String[] layoutTokens = LayoutInfo.createLayoutTokens((String)
- layout.getAttributes().get(ATTR_COLUMNS), columnCount);
+ final LayoutTokens layoutTokens = layout.getColumnLayout();
+ layoutTokens.ensureSize(columnCount, new RelativeLayoutToken(1));
+ //LayoutInfo.createLayoutTokens((String)
+ //layout.getAttributes().get(ATTR_COLUMNS), columnCount);
if (!rows.isEmpty()) {
UIGridLayout.Row row = rows.get(0);
@@ -522,7 +532,7 @@
}
}
if (hidden) {
- layoutTokens[i] = LayoutInfo.HIDE_CELL;
+ layoutTokens.set(i, new HideLayoutToken());
}
}
}
@@ -551,9 +561,11 @@
FacesContext facesContext) {
final List<UIGridLayout.Row> rows = layout.ensureRows();
- String[] layoutTokens = LayoutInfo.createLayoutTokens(
+ LayoutTokens layoutTokens = layout.getRowLayout();
+ layoutTokens.ensureSize(rows.size(), rows.size() == 1 ? new RelativeLayoutToken(1) : new FixedLayoutToken());
+ /*LayoutInfo.createLayoutTokens(
(String) layout.getAttributes().get(ATTR_ROWS),
- rows.size(), rows.size() == 1 ? "1*" : "fixed");
+ rows.size(), rows.size() == 1 ? "1*" : "fixed");*/
for (int i = 0; i < rows.size(); i++) {
boolean hidden = true;
@@ -564,16 +576,15 @@
}
row.setHidden(hidden);
if (hidden) {
- layoutTokens[i] = LayoutInfo.HIDE_CELL;
+ layoutTokens.set(i, new HideLayoutToken());
}
}
LayoutInfo layoutInfo =
- new LayoutInfo(rows.size(), innerHeight.intValue(),
- layoutTokens, layout.isIgnoreFree());
+ new LayoutInfo(rows.size(), innerHeight.intValue(), layoutTokens);
- if (layoutInfo.hasLayoutTokens()) {
+ if (!layoutTokens.isEmpty()) {
parseFixedHeight(layoutInfo, layout, facesContext);
layoutInfo.parseColumnLayout(innerHeight.doubleValue(),
getCellSpacing(facesContext, layout));
@@ -591,12 +602,47 @@
FacesContext facesContext) {
parseFixedSpace(layoutInfo, layout, false, facesContext);
}
+
+ public void parseFixedSpace(LayoutInfo layoutInfo, UIGridLayout layout,
+ LayoutTokens layoutTokens, boolean width, FacesContext facesContext) {
+
+ //String[] tokens = layoutInfo.getLayoutTokens();
+ for (int i = 0; i < layoutTokens.getSize(); i++) {
+ LayoutToken token = layoutTokens.get(i);
+ if (token instanceof FixedLayoutToken) {
+ int max = 0;
+ final List<UIGridLayout.Row> rows = layout.ensureRows();
+ if (!rows.isEmpty()) {
+ if (width) {
+ max = getMaxWidth(facesContext, rows, i, false);
+ } else {
+ if (i < rows.size()) { //
+ UIGridLayout.Row row = rows.get(i);
+ max = getMaxHeight(facesContext, row, false);
+ } else {
+ layoutInfo.update(0, i);
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("More LayoutTokens found than rows! skipping! tokens = "
+ + token + " components = "
+ + rows.size());
+ }
+ }
+ }
+ layoutInfo.update(max, i);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("set column " + i + " from fixed to with " + max);
+ }
+ }
+ }
+ }
private void parseFixedSpace(LayoutInfo layoutInfo, UIGridLayout layout,
boolean width, FacesContext facesContext) {
- String[] tokens = layoutInfo.getLayoutTokens();
- for (int i = 0; i < tokens.length; i++) {
- if (tokens[i].equals("fixed")) {
+ LayoutTokens tokens = layoutInfo.getLayoutTokens();
+ for (int i = 0; i < tokens.getSize(); i++) {
+ LayoutToken token = tokens.get(i);
+ if (token instanceof FixedLayoutToken) {
int max = 0;
final List<UIGridLayout.Row> rows = layout.ensureRows();
if (!rows.isEmpty()) {
@@ -610,7 +656,7 @@
layoutInfo.update(0, i);
if (LOG.isWarnEnabled()) {
LOG.warn("More LayoutTokens found than rows! skipping! tokens = "
- + LayoutInfo.tokensToString(tokens) + " components = "
+ + token + " components = "
+ rows.size());
}
}
@@ -734,7 +780,7 @@
cellHeight += (spanY - 1) * getCellSpacing(facesContext, layout);
if (LOG.isDebugEnabled()) {
LOG.debug("set height of " + cellHeight + "px to "
- + cell.getRendererType());
+ + cell.getRendererType() + " layoutInfo " + layoutInfo.toString());
}
cell.getAttributes().put(ATTR_LAYOUT_HEIGHT, Integer.valueOf(cellHeight));
cell.getAttributes().remove(ATTR_INNER_HEIGHT);
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java Thu May 3 06:15:29 2007
@@ -162,7 +162,7 @@
String popupId = id + SUBCOMPONENT_SEP + "ajaxPopup";
- final UIPage page = ComponentUtil.findPage(component);
+ final UIPage page = ComponentUtil.findPage(facesContext, component);
page.getScriptFiles().add("script/effects.js");
page.getScriptFiles().add("script/dragdrop.js");
page.getScriptFiles().add("script/controls.js");
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java Thu May 3 06:15:29 2007
@@ -141,7 +141,7 @@
protected void addScriptsAndStyles(FacesContext facesContext,
UIComponent component, final String clientId, String setupFunction,
String scriptBlock) throws IOException {
- final UIPage page = ComponentUtil.findPage(component);
+ final UIPage page = ComponentUtil.findPage(facesContext, component);
page.getScriptFiles().add("script/tobago-menu.js");
page.getStyleFiles().add("style/tobago-menu.css");
String function = setupFunction + "('" + clientId + "', '"
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java Thu May 3 06:15:29 2007
@@ -94,7 +94,7 @@
}
}
if (focusId != null) {
- ComponentUtil.findPage(component).setFocusId(focusId);
+ ComponentUtil.findPage(facesContext, component).setFocusId(focusId);
}
writer.endElement(HtmlConstants.SPAN);
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java Thu May 3 06:15:29 2007
@@ -71,7 +71,7 @@
}
super.decode(facesContext, component);
- String actionId = ComponentUtil.findPage(component).getActionId();
+ String actionId = ComponentUtil.findPage(facesContext, component).getActionId();
if (actionId != null
&& actionId.equals(component.getClientId(facesContext) + CHANGE_BUTTON)) {
boolean state
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Thu May 3 06:15:29 2007
@@ -70,6 +70,7 @@
import org.apache.myfaces.tobago.component.UIMenuCommand;
import org.apache.myfaces.tobago.component.UIReload;
import org.apache.myfaces.tobago.component.UICommand;
+import org.apache.myfaces.tobago.component.UIPage;
import org.apache.myfaces.tobago.config.TobagoConfig;
import org.apache.myfaces.tobago.context.ResourceManager;
import org.apache.myfaces.tobago.context.ResourceManagerFactory;
@@ -77,8 +78,8 @@
import org.apache.myfaces.tobago.event.PageAction;
import org.apache.myfaces.tobago.model.SheetState;
import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.SheetRendererWorkaround;
import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.SheetRendererWorkaround;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
@@ -166,12 +167,12 @@
"new Tobago.Sheet(\"" + sheetId + "\", " + ajaxEnabled
+ ", \"" + checked + "\", \"" + unchecked + "\", \"" + data.getSelectable() + "\", "+ frequency + ");"
};
-
- ComponentUtil.addStyles(data, styles);
- ComponentUtil.addScripts(data, scripts);
+ UIPage page = ComponentUtil.findPage(facesContext, data);
+ page.getStyleFiles().add(styles[0]);
+ page.getScriptFiles().add(scripts[0]);
if (!ajaxEnabled) {
- ComponentUtil.addOnloadCommands(data, cmds);
+ page.getOnloadScripts().add(cmds[0]);
} else {
HtmlRendererUtil.writeStyleLoader(facesContext, styles);
HtmlRendererUtil.writeScriptLoader(facesContext, scripts, cmds);
@@ -1085,7 +1086,7 @@
if (ajaxId.equals(component.getClientId(facesContext))) {
if (component.getFacet(FACET_RELOAD) != null && component.getFacet(FACET_RELOAD) instanceof UIReload
&& component.getFacet(FACET_RELOAD).isRendered()
- && ajaxId.equals(ComponentUtil.findPage(component).getActionId())) {
+ && ajaxId.equals(ComponentUtil.findPage(facesContext, component).getActionId())) {
UIReload reload = (UIReload) component.getFacet(FACET_RELOAD);
update = reload.getUpdate();
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Thu May 3 06:15:29 2007
@@ -107,7 +107,7 @@
final String switchType = component.getSwitchType();
- UIPage page = ComponentUtil.findPage(component);
+ UIPage page = ComponentUtil.findPage(facesContext, component);
final String[] scripts = new String[]{
"script/tab.js",
"script/tabgroup.js"
@@ -255,7 +255,7 @@
|| SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
onclick = "tobago_requestTab('"
+ clientId + "'," + index + ",'"
- + ComponentUtil.findPage(component).getFormId(facesContext) + "')";
+ + ComponentUtil.findPage(facesContext, component).getFormId(facesContext) + "')";
} else { // SWITCH_TYPE_CLIENT
onclick = "tobago_selectTab('"
+ clientId + "'," + index + ','
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java Thu May 3 06:15:29 2007
@@ -60,7 +60,7 @@
public void encodeEnd(FacesContext facesContext,
UIComponent component) throws IOException {
- UIPage page = ComponentUtil.findPage(component);
+ UIPage page = ComponentUtil.findPage(facesContext, component);
for (String script : SCRIPTS) {
page.getScriptFiles().add(script);
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java?view=diff&rev=534844&r1=534843&r2=534844
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java Thu May 3 06:15:29 2007
@@ -60,7 +60,7 @@
UITreeOldNode root = tree.getRoot();
- UIPage page = ComponentUtil.findPage(tree);
+ UIPage page = ComponentUtil.findPage(facesContext, tree);
if (LOG.isDebugEnabled()) {
page.getOnloadScripts().add("tbgTreeStates('" + clientId + "')");
}
@@ -101,7 +101,7 @@
String scriptText = createJavascript(facesContext, clientId, root);
String[] scripts = {"script/tree.js"};
- List<String> scriptFiles = ComponentUtil.findPage(tree).getScriptFiles();
+ List<String> scriptFiles = ComponentUtil.findPage(facesContext, tree).getScriptFiles();
for (String script : scripts) {
scriptFiles.add(script);
}