Author: ekoneil Date: Sun Jan 23 11:04:39 2005 New Revision: 126240 URL: http://svn.apache.org/viewcvs?view=rev&rev=126240 Log: Implement empty style policy mentioned in previous change.
Now, styles can be scoped to a <div> as: #foo tr.header and so on. Add a test of this both inside of and outside of a div. BB: self DRT: NetUI / datagrid pass Added: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/style/EmptyStylePolicy.java (contents, props changed) incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/datagrid/misc/emptyStylePolicy.jsp (contents, props changed) incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/DataGridEmptyStylePolicy.xml (contents, props changed) Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Added: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/style/EmptyStylePolicy.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/style/EmptyStylePolicy.java?view=auto&rev=126240 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/style/EmptyStylePolicy.java Sun Jan 23 11:04:39 2005 @@ -0,0 +1,29 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.databinding.datagrid.model.style; + +/** + * + */ +public class EmptyStylePolicy + extends DefaultStylePolicy { + + protected String buildStyleClass(String baseStyle) { + return baseStyle; + } +} Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java?view=diff&rev=126240&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java&r1=126239&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java&r2=126240 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java (original) +++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java Sun Jan 23 11:04:39 2005 @@ -30,6 +30,7 @@ import org.apache.beehive.netui.databinding.datagrid.model.PagerModel; import org.apache.beehive.netui.databinding.datagrid.model.style.StylePolicy; import org.apache.beehive.netui.databinding.datagrid.model.style.DefaultStylePolicy; +import org.apache.beehive.netui.databinding.datagrid.model.style.EmptyStylePolicy; import org.apache.beehive.netui.databinding.datagrid.util.PagedDataSet; import org.apache.beehive.netui.databinding.datagrid.rendering.table.TableRenderer; import org.apache.beehive.netui.script.common.IDataAccessProvider; @@ -52,9 +53,13 @@ implements IDataAccessProvider { private static final StylePolicy DEFAULT_STYLE_POLICY = new DefaultStylePolicy("datagrid"); + private static final StylePolicy EMPTY_STYLE_POLICY = new EmptyStylePolicy(); + private static final String EMPTY_STYLE_POLICY_NAME = "empty"; + private static final String DEFAULT_STYLE_POLICY_NAME = "default"; private String _name = null; private String _styleClassPrefix = null; + private String _stylePolicyName = null; private String _dataSource = null; private String _resourceBundlePath = null; private DataGridModel _gridModel = null; @@ -92,6 +97,13 @@ _resourceBundlePath = resourceBundlePath; } + /** + * @netui:attribute required="false" rtexprvalue="true" + */ + public void setStyleClassPolicy(String stylePolicy) { + _stylePolicyName = stylePolicy; + } + /* todo: should this be wrapped in try / finally so that the PageContext gets cleaned up correctly? */ public void doTag() throws JspException, IOException { @@ -109,9 +121,13 @@ PagedDataSet dataSet = new PagedDataSet(dataSource, iterator); /* todo: extensibility -- need to go to a factory with this */ - if(_styleClassPrefix != null) - stylePolicy = new DefaultStylePolicy(_styleClassPrefix); - else stylePolicy = DEFAULT_STYLE_POLICY; + if(_stylePolicyName == null || _stylePolicyName.equals(DEFAULT_STYLE_POLICY_NAME)) { + if(_styleClassPrefix != null) + stylePolicy = new DefaultStylePolicy(_styleClassPrefix); + else stylePolicy = DEFAULT_STYLE_POLICY; + } + else if(_stylePolicyName != null && _stylePolicyName.equals(EMPTY_STYLE_POLICY_NAME)) + stylePolicy = EMPTY_STYLE_POLICY; TableRenderer tableRenderer = new TableRenderer(request, stylePolicy); Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/datagrid/misc/emptyStylePolicy.jsp Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/datagrid/misc/emptyStylePolicy.jsp?view=auto&rev=126240 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/datagrid/misc/emptyStylePolicy.jsp Sun Jan 23 11:04:39 2005 @@ -0,0 +1,51 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%> +<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%> +<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> +<%@ taglib prefix="datagrid" tagdir="/WEB-INF/tags/org/apache/beehive/netui/test/databinding/tagfiles" %> +<netui:html> + <head> + <title>CSS Prefix Test</title> + <style type="text/css"> + tr.header { + background-color: #5f7797; + } + tr.even { + background-color: #ffffff; + } + tr.odd { + background-color: #bfc4cb; + } + #stocks tr.header { + background-color: #bfc4cb; + } + #stocks tr.even { + background-color: #ffffff; + } + #stocks tr.odd { + background-color: #5f7797; + } + </style> + </head> + <netui:body> + <p> + <datagrid:portfolioXmlBean/> + <netui-data:dataGrid dataSource="pageScope.stocks" name="stocks" styleClassPolicy="empty"> + <netui-data:columns> + <netui-data:spanColumn headerText="Symbol" value="${container.item.symbol}"/> + <netui-data:spanColumn headerText="Price" value="${container.item.price}"/> + </netui-data:columns> + </netui-data:dataGrid> + <br/> + <div id="stocks"> + <netui-data:dataGrid dataSource="pageScope.stocks" name="stocks" styleClassPolicy="empty"> + <netui-data:columns> + <netui-data:spanColumn headerText="Symbol" value="${container.item.symbol}"/> + <netui-data:spanColumn headerText="Price" value="${container.item.price}"/> + </netui-data:columns> + </netui-data:dataGrid> + </div> + </p> + </netui:body> +</netui:html> \ No newline at end of file Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&rev=126240&p1=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r1=126239&p2=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r2=126240 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Sun Jan 23 11:04:39 2005 @@ -2489,6 +2489,21 @@ </features> </test> <test> + <name>DataGridEmptyStylePolicy</name> + <description>DataGridEmptyStylePolicy</description> + <webapp>coreWeb</webapp> + <categories> + <category>bvt</category> + <category>bvt.struts11</category> + <category>databinding</category> + <category>datagrid</category> + </categories> + <features> + <feature>Databinding</feature> + <feature>Data Grid</feature> + </features> + </test> + <test> <name>DataGridFooterTest</name> <description>DataGridFooterTest</description> <webapp>coreWeb</webapp> Added: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/DataGridEmptyStylePolicy.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/DataGridEmptyStylePolicy.xml?view=auto&rev=126240 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/DataGridEmptyStylePolicy.xml Sun Jan 23 11:04:39 2005 @@ -0,0 +1,219 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session"> + <ses:sessionName>DataGridEmptyStylePolicy</ses:sessionName> + <ses:tester>ekoneil</ses:tester> + <ses:startDate>23 Jan 2005, 11:49:39.662 AM MST</ses:startDate> + <ses:description>Test rendering two grids. One with styles scoped to a <div> another with global styles. Both use an "empty" style policy.</ses:description> + <ses:tests> + <ses:test> + <ses:testNumber>1</ses:testNumber> + <ses:request> + <ses:protocol>HTTP</ses:protocol> + <ses:protocolVersion>1.1</ses:protocolVersion> + <ses:host>localhost</ses:host> + <ses:port>8080</ses:port> + <ses:uri>/coreWeb/databinding/datagrid/misc/emptyStylePolicy.jsp</ses:uri> + <ses:method>GET</ses:method> + <ses:parameters/> + <ses:cookies> + <ses:cookie> + <ses:name>JSESSIONID</ses:name> + <ses:value>E1A8FCBF5C9C80D0C370F9BA6C3CFC47</ses:value> + </ses:cookie> + </ses:cookies> + <ses:headers> + <ses:header> + <ses:name>accept</ses:name> + <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value> + </ses:header> + <ses:header> + <ses:name>accept-charset</ses:name> + <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value> + </ses:header> + <ses:header> + <ses:name>accept-encoding</ses:name> + <ses:value>gzip,deflate</ses:value> + </ses:header> + <ses:header> + <ses:name>accept-language</ses:name> + <ses:value>en-us,en;q=0.5</ses:value> + </ses:header> + <ses:header> + <ses:name>connection</ses:name> + <ses:value>keep-alive</ses:value> + </ses:header> + <ses:header> + <ses:name>cookie</ses:name> + <ses:value>JSESSIONID=E1A8FCBF5C9C80D0C370F9BA6C3CFC47</ses:value> + </ses:header> + <ses:header> + <ses:name>host</ses:name> + <ses:value>localhost:8080</ses:value> + </ses:header> + <ses:header> + <ses:name>keep-alive</ses:name> + <ses:value>300</ses:value> + </ses:header> + <ses:header> + <ses:name>user-agent</ses:name> + <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0</ses:value> + </ses:header> + </ses:headers> + </ses:request> + <ses:response> + <ses:statusCode>200</ses:statusCode> + <ses:reason/> + <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> + + <head> + <title>CSS Prefix Test</title> + <style type="text/css"> + tr.header { + background-color: #5f7797; + } + tr.even { + background-color: #ffffff; + } + tr.odd { + background-color: #bfc4cb; + } + #stocks tr.header { + background-color: #bfc4cb; + } + #stocks tr.even { + background-color: #ffffff; + } + #stocks tr.odd { + background-color: #5f7797; + } + </style> + </head> + <body> + <p> + + + + + + + Page 1 of 1 +<table> + + +<thead> +<tr class="header"> + <th>Symbol</th> + + + <th>Price</th> + + + +</tr></thead> + +<tr class="even"> + <td><span>BEAS</span></td> + + <td><span>14.35</span></td> + + +</tr> +<tr class="odd"> + <td><span>CSCO</span></td> + + <td><span>19.42</span></td> + + +</tr> +<tr class="even"> + <td><span>GE</span></td> + + <td><span>59.42</span></td> + + +</tr> +<tr class="odd"> + <td><span>RHAT</span></td> + + <td><span>18.2</span></td> + + +</tr> +<tr class="even"> + <td><span>YHOO</span></td> + + <td><span>48.16</span></td> + + +</tr> + </table> + + + <br/> + <div id="stocks"> + Page 1 of 1 +<table> + + +<thead> +<tr class="header"> + <th>Symbol</th> + + + <th>Price</th> + + + +</tr></thead> + +<tr class="even"> + <td><span>BEAS</span></td> + + <td><span>14.35</span></td> + + +</tr> +<tr class="odd"> + <td><span>CSCO</span></td> + + <td><span>19.42</span></td> + + +</tr> +<tr class="even"> + <td><span>GE</span></td> + + <td><span>59.42</span></td> + + +</tr> +<tr class="odd"> + <td><span>RHAT</span></td> + + <td><span>18.2</span></td> + + +</tr> +<tr class="even"> + <td><span>YHOO</span></td> + + <td><span>48.16</span></td> + + +</tr> + </table> + + + </div> + </p> + </body> + +</html>]]></ses:responseBody> + </ses:response> + </ses:test> + </ses:tests> + <ses:endDate>23 Jan 2005, 11:49:45.631 AM MST</ses:endDate> + <ses:testCount>1</ses:testCount> +</ses:recorderSession> \ No newline at end of file
