Author: sergeyhalipov
Date: 2008-03-26 13:10:49 -0400 (Wed, 26 Mar 2008)
New Revision: 7269
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererDelegate.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
trunk/ui/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java
trunk/ui/orderingList/src/test/java/org/richfaces/renderkit/OrderingListRenderingTest.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2726
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -119,7 +119,7 @@
// Filter not used - encode scripts and CSS before component.
ExternalContext externalContext = context.getExternalContext();
String scriptStrategy = externalContext
- .getInitParameter(InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM);
+ .getInitParameter(InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM);
if (null == scriptStrategy ||
!InternetResourceBuilder.LOAD_NONE.equals(scriptStrategy)) {
encodeResourcesArray(context, component, getScripts());
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -239,6 +239,7 @@
public static final String SPAN_ELEM = "span";
public static final String DIV_ELEM = "div";
public static final String SCRIPT_ELEM = "script";
+ public static final String LINK_ELEMENT = "link";
public static final String STYLE_CLASS_ATTR = "styleClass";
public static final String DISABLED_ATTR = "disabled";
public static final String TYPE_ATTR = "type";
@@ -264,12 +265,16 @@
public static final String HTML_ELEMENT = "html";
public static final String HEAD_ELEMENT = "head";
public static final String BODY_ELEMENT = "body";
+ public static final String TABLE_ELEMENT = "table";
public static final String TR_ELEMENT = "tr";
public static final String CAPTION_ELEMENT = "caption";
public static final String TBOBY_ELEMENT = "tbody";
public static final String THEAD_ELEMENT = "thead";
public static final String TFOOT_ELEMENT = "tfoot";
public static final String IMG_ELEMENT = "img";
+
+ public static final String DT_ELEMENT = "dt";
+ public static final String DL_ELEMENT = "dl";
}
/**
Modified:
trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
===================================================================
---
trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -15,13 +15,13 @@
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlForm;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.html.HtmlButton;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlImage;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
@@ -73,11 +73,8 @@
.createComponent(UICalendar.COMPONENT_TYPE);
calendar.setLocale(Locale.UK);
calendar.setDatePattern("d/MM/yyyy");
- calendar.setTimeZone(TimeZone.getTimeZone("GMT+10:00"));
- /*
- * String[] strarr = TimeZone.getAvailableIDs(); for(int i=0; i <
- * strarr.length; i++){ System.out.println(strarr[i]); }
- */
+ calendar.setTimeZone(TimeZone.getTimeZone("GMT-4:00"));
+
calendar.setButtonLabel("PopUp");
// XXX test popup false
// XXX test CurrentDate = null
@@ -176,7 +173,6 @@
HtmlPage page = renderView();
assertNotNull(page);
- //System.out.println(page.asXml());
HtmlElement htmlSpan =
page.getHtmlElementById(calendar.getClientId(facesContext)+"Popup");
assertNotNull(htmlSpan);
@@ -199,7 +195,7 @@
HtmlElement htmlCalendar1Span = page.getHtmlElementById(calendar1
.getClientId(facesContext)+"Popup");
assertNotNull(htmlCalendar1Span);
- assertEquals("display: none",
htmlCalendar1Span.getAttributeValue("style"));
+ assertEquals("display: none",
htmlCalendar1Span.getAttributeValue(HTML.style_ATTRIBUTE));
try {
HtmlInput htmlCalendarInput1 = (HtmlInput) page
@@ -223,7 +219,6 @@
} catch (ElementNotFoundException e) {
assertNotNull(e);
}
- //System.out.println(page.asXml());
}
public void testCalendarDecode() throws Exception {
@@ -241,24 +236,23 @@
public void testCalendarStyles() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- //System.out.println(page.asXml());
- List links = page.getDocumentElement().getHtmlElementsByTagName("link");
+
+ List links =
page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
assertEquals(1, links.size());
HtmlElement link = (HtmlElement) links.get(0);
- assertTrue(link.getAttributeValue("href").contains("css/calendar.xcss"));
+ assertTrue(link.getAttributeValue(HTML.HREF_ATTR).contains("css/calendar.xcss"));
}
public void testCalendarScrits() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List scripts = page.getDocumentElement().getHtmlElementsByTagName(
- "script");
- for (Iterator it = scripts.iterator(); it.hasNext();) {
- HtmlScript item = (HtmlScript) it.next();
+ List<HtmlScript> scripts =
page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.SCRIPT_ELEM);
+ for (Iterator<HtmlScript> it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = it.next();
String srcAttr = item.getSrcAttribute();
- if (item.getFirstChild() != null) {
- String scriptBodyString = item.getFirstChild().toString();
+ if (item.getFirstDomChild() != null) {
+ String scriptBodyString = item.getFirstDomChild().toString();
if (scriptBodyString.contains("new
Calendar")&&scriptBodyString.contains("form:calendar")) {
assertTrue(scriptBodyString.contains("datePattern"));
@@ -276,8 +270,8 @@
if (StringUtils.isNotBlank(srcAttr)) {
boolean found = false;
- for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
- String src = (String) srcIt.next();
+ for (Iterator<String> srcIt = javaScripts.iterator(); srcIt.hasNext();) {
+ String src = srcIt.next();
found = srcAttr.contains(src);
if (found) {
break;
@@ -289,11 +283,9 @@
}
public void testCalendarTime() throws Exception{
-
- Date time = (Date) calendar2.getValue();
Calendar calendarObject = Calendar.getInstance();
calendarObject.set(2001, Calendar.SEPTEMBER, 11, 13, 36);
- assertEquals(calendarObject.getTime(), calendar2.getSubmittedValue());
+ assertEquals(0,
calendarObject.getTime().compareTo((Date)calendar2.getSubmittedValue()));
}
Modified:
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java
===================================================================
---
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -112,11 +112,6 @@
* @throws Exception
*/
public void testDecode() throws Exception {
- HtmlPage view = renderView();
- assertNotNull(view);
-
- HtmlAnchor anchor =
(HtmlAnchor)view.getDocumentElement().getHtmlElementById(command.getClientId(facesContext));
- anchor.click();
externalContext.addRequestParameterMap(listShuttle.getClientId(facesContext),
"sa1:2");
externalContext.addRequestParameterMap(listShuttle.getClientId(facesContext),
"0:1");
externalContext.addRequestParameterMap(listShuttle.getClientId(facesContext),
":");
Modified:
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java
===================================================================
---
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -33,6 +33,7 @@
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpServletResponse;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
@@ -51,14 +52,14 @@
private UIListShuttle listShuttle = null;
private UIForm form = null;
- private List items = null;
+ private List<SimpleItem> items = null;
private HtmlOutputText output1 = null;
private HtmlOutputText output2 = null;
private UIColumn column1 = null;
private UIColumn column2 = null;
- private static final Set javaScripts = new HashSet();
- private static final Set imageClasses = new HashSet();
+ private static final Set<String> javaScripts = new HashSet<String>();
+ private static final Set<String> imageClasses = new HashSet<String>();
static {
javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
@@ -114,7 +115,7 @@
listShuttle.setId("listShuttle");
listShuttle.setVar("item");
- items = new ArrayList();
+ items = new ArrayList<SimpleItem>();
items.add(new SimpleItem("Michael", 2000));
items.add(new SimpleItem("John", 500));
items.add(new SimpleItem("George", 4000));
@@ -159,46 +160,49 @@
HtmlElement table =
view.getHtmlElementById(listShuttle.getClientId(facesContext));
assertNotNull(table);
- assertEquals("table", table.getNodeName());
+ assertEquals(HTML.TABLE_ELEMENT, table.getNodeName());
- HtmlElement tbody = (HtmlElement) table.getFirstChild();
+ HtmlElement tbody = (HtmlElement) table.getFirstDomChild();
assertNotNull(tbody);
- assertEquals("tbody", tbody.getTagName());
+ assertEquals(HTML.TBOBY_ELEMENT, tbody.getTagName());
- HtmlElement tr = (HtmlElement) tbody.getFirstChild();
+ HtmlElement tr = (HtmlElement) tbody.getFirstDomChild();
assertNotNull(tr);
- String style = tr.getAttributeValue("style");
+ String style = tr.getAttributeValue(HTML.style_ATTRIBUTE);
assertNotNull(style);
assertTrue(style.contains("display: none;"));
- assertEquals("tr", tr.getTagName());
+ assertEquals(HTML.TR_ELEMENT, tr.getTagName());
- tr = (HtmlElement) tr.getNextSibling();
+ tr = (HtmlElement) tr.getNextDomSibling();
assertNotNull(tr);
- assertNull(tr.getNextSibling());
+ assertNull(tr.getNextDomSibling());
int childCount = 0;
- for (Iterator it = tr.getChildIterator(); it.hasNext();) {
- HtmlElement td = (HtmlElement) it.next();
+ for (Iterator<HtmlElement> it = tr.getChildIterator(); it.hasNext();) {
+ HtmlElement td = it.next();
assertNotNull(td);
- assertEquals("td", td.getTagName());
+ assertEquals(HTML.td_ELEM, td.getTagName());
childCount++;
}
assertEquals(4, childCount);
HtmlElement hidden1 =
view.getHtmlElementById(listShuttle.getClientId(facesContext) + "focusKeeper");
assertNotNull(hidden1);
- assertEquals("input", hidden1.getNodeName());
- assertEquals("button", hidden1.getAttributeValue("type"));
- hidden1.getAttributeValue("style").contains("left:
-32767px");
+ assertEquals(HTML.INPUT_ELEM, hidden1.getNodeName());
+ assertEquals(HTML.BUTTON, hidden1.getAttributeValue(HTML.TYPE_ATTR));
+ hidden1.getAttributeValue(HTML.style_ATTRIBUTE).contains("left:
-32767px");
- List inputs =
view.getDocumentElement().getHtmlElementsByAttribute("input", "id",
listShuttle.getClientId(facesContext) + "focusKeeper");
+ List<HtmlElement> inputs = view.getDocumentHtmlElement().
+ getHtmlElementsByAttribute(HTML.INPUT_ELEM, HTML.id_ATTRIBUTE,
listShuttle.getClientId(facesContext) + "focusKeeper");
assertNotNull(inputs);
assertEquals(1, inputs.size());
- inputs = view.getDocumentElement().getHtmlElementsByAttribute("input",
"id", listShuttle.getClientId(facesContext) + "tlFocusKeeper");
+ inputs = view.getDocumentHtmlElement().
+ getHtmlElementsByAttribute(HTML.INPUT_ELEM, HTML.id_ATTRIBUTE,
listShuttle.getClientId(facesContext) + "tlFocusKeeper");
assertNotNull(inputs);
assertEquals(1, inputs.size());
- inputs = view.getDocumentElement().getHtmlElementsByAttribute("input",
"name", listShuttle.getClientId(facesContext));
+ inputs = view.getDocumentHtmlElement().
+ getHtmlElementsByAttribute(HTML.INPUT_ELEM, HTML.NAME_ATTRIBUTE,
listShuttle.getClientId(facesContext));
assertNotNull(inputs);
assertEquals(4, inputs.size());
}
@@ -211,15 +215,15 @@
public void testRenderScript() throws Exception {
HtmlPage view = renderView();
assertNotNull(view);
- List scripts =
view.getDocumentElement().getHtmlElementsByTagName("script");
+ List<HtmlScript> scripts =
view.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.SCRIPT_ELEM);
int foundCount = 0;
- for (Iterator it = scripts.iterator(); it.hasNext();) {
- HtmlScript item = (HtmlScript) it.next();
+ for (Iterator<HtmlScript> it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = it.next();
String srcAttr = item.getSrcAttribute();
if (StringUtils.isNotBlank(srcAttr)) {
boolean found = false;
- for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
+ for (Iterator<String> srcIt = javaScripts.iterator();
srcIt.hasNext();) {
String src = (String) srcIt.next();
found = srcAttr.contains(src);
@@ -249,13 +253,13 @@
public void testRenderStyle() throws Exception {
HtmlPage view = renderView();
assertNotNull(view);
- List links =
view.getDocumentElement().getHtmlElementsByTagName("link");
+ List<HtmlElement> links =
view.getDocumentElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
assertNotNull(links);
assertEquals(1, links.size());
- HtmlElement link = (HtmlElement) links.get(0);
-
assertTrue(link.getAttributeValue("href").contains("css/listShuttle.xcss"));
+ HtmlElement link = links.get(0);
+
assertTrue(link.getAttributeValue(HTML.HREF_ATTR).contains("css/listShuttle.xcss"));
- String uri = "http:" + link.getAttributeValue("href");
+ String uri = "http:" + link.getAttributeValue(HTML.HREF_ATTR);
Page page = webClient.getPage(uri);
assertNotNull(page);
assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
@@ -270,15 +274,15 @@
HtmlPage view = renderView();
assertNotNull(view);
- List images =
view.getDocumentElement().getHtmlElementsByTagName("img");
+ List<HtmlElement> images =
view.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.IMG_ELEMENT);
assertNotNull(images);
int foundImages = 0;
- for (Iterator it = images.iterator(); it.hasNext(); ) {
- HtmlElement img = (HtmlElement) it.next();
+ for (Iterator<HtmlElement> it = images.iterator(); it.hasNext(); ) {
+ HtmlElement img = it.next();
assertNotNull(img);
- String uri = "http:" + img.getAttributeValue("src");
+ String uri = "http:" + img.getAttributeValue(HTML.src_ATTRIBUTE);
Page page = webClient.getPage(uri);
assertNotNull(page);
assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
@@ -288,26 +292,23 @@
}
foundImages++;
- HtmlElement element = (HtmlElement) img.getParentNode();
+ HtmlElement element = (HtmlElement) img.getParentDomNode();
assertNotNull(element);
- assertEquals("div", element.getNodeName());
+ assertEquals(HTML.DIV_ELEM, element.getNodeName());
- element = (HtmlElement) element.getParentNode();
+ element = (HtmlElement) element.getParentDomNode();
assertNotNull(element);
- assertEquals("a", element.getNodeName());
- element = (HtmlElement) element.getParentNode();
- assertNotNull(element);
- if ("a".equalsIgnoreCase(element.getNodeName())) {
- element = (HtmlElement) element.getParentNode();
+ if (HTML.a_ELEMENT.equalsIgnoreCase(element.getNodeName())) {
+ element = (HtmlElement) element.getParentDomNode();
assertNotNull(element);
}
- assertEquals("div", element.getNodeName());
+ assertEquals(HTML.DIV_ELEM, element.getNodeName());
- element = (HtmlElement) element.getParentNode();
+ element = (HtmlElement) element.getParentDomNode();
assertNotNull(element);
- assertEquals("div", element.getNodeName());
- String clazz = element.getAttributeValue("class");
+ assertEquals(HTML.DIV_ELEM, element.getNodeName());
+ String clazz = element.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz);
assertTrue(clazz.contains("rich-shuttle-control"));
}
@@ -325,8 +326,8 @@
InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
- for (Iterator it = imageClasses.iterator(); it.hasNext(); ) {
- String clazz = (String) it.next();
+ for (Iterator<String> it = imageClasses.iterator(); it.hasNext(); ) {
+ String clazz = it.next();
builder.createResource(null, clazz);
InternetResource resource = builder.getResource(clazz);
assertNotNull(resource);
@@ -354,33 +355,33 @@
HtmlElement div = view.getHtmlElementById(listShuttle.getClientId(facesContext) +
"contentBox");
assertNotNull(div);
- assertEquals("div", div.getNodeName());
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
- HtmlElement table = (HtmlElement)div.getFirstChild();
+ HtmlElement table = (HtmlElement)div.getFirstDomChild();
assertNotNull(table);
- assertEquals("table", table.getNodeName());
+ assertEquals(HTML.TABLE_ELEMENT, table.getNodeName());
- HtmlElement tbody = (HtmlElement)table.getFirstChild();
+ HtmlElement tbody = (HtmlElement)table.getFirstDomChild();
assertNotNull(tbody);
- assertEquals("tbody", tbody.getNodeName());
+ assertEquals(HTML.TBOBY_ELEMENT, tbody.getNodeName());
int rowsCount = 0;
- for (Iterator it = tbody.getChildIterator(); it.hasNext(); ) {
- HtmlElement tr = (HtmlElement)it.next();
+ for (Iterator<HtmlElement> it = tbody.getChildIterator(); it.hasNext(); )
{
+ HtmlElement tr = it.next();
assertNotNull(tr);
- assertEquals("tr", tr.getNodeName());
+ assertEquals(HTML.TR_ELEMENT, tr.getNodeName());
- String clazz = tr.getAttributeValue("class");
+ String clazz = tr.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz);
assertTrue(clazz.contains("rich-shuttle-source-row"));
int cellsCount = 0;
- for (Iterator it2 = tr.getChildIterator(); it2.hasNext(); ) {
- HtmlElement td = (HtmlElement)it2.next();
+ for (Iterator<HtmlElement> it2 = tr.getChildIterator(); it2.hasNext();
) {
+ HtmlElement td = it2.next();
assertNotNull(td);
- assertEquals("td", td.getNodeName());
+ assertEquals(HTML.td_ELEM, td.getNodeName());
- String clazz2 = td.getAttributeValue("class");
+ String clazz2 = td.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz2);
assertTrue(clazz2.contains("rich-shuttle-source-cell"));
Modified:
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererDelegate.java
===================================================================
---
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererDelegate.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererDelegate.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -40,7 +40,7 @@
Object selectItemClass = parentMenu.getAttributes().get("selectItemClass");
Object selectClass = menuItem.getAttributes().get("selectClass");
Object styleClass = menuItem.getAttributes().get("styleClass");
- Object style = parentMenu.getAttributes().get("style");
+ Object style = menuItem.getAttributes().get("style");
Object labelClass = (String)menuItem.getAttributes().get("labelClass");
Object disabledLabelClass =
(String)menuItem.getAttributes().get("labelClass");
Object selectedLabelClass =
(String)menuItem.getAttributes().get("labelClass");
Modified:
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
===================================================================
---
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -32,6 +32,7 @@
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpServletResponse;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
@@ -114,10 +115,10 @@
public void testMenuGroupRender() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
+
HtmlElement div = page.getHtmlElementById(menuGroup.getClientId(facesContext));
assertNotNull(div);
- assertEquals("div", div.getNodeName());
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
}
@@ -129,13 +130,12 @@
menuGroup.getFacets().clear();
menuGroup.getAttributes().put("icon", "menuGroupIcon");
HtmlPage page = renderView();
- // System.out.println(page.asXml());
+
assertNotNull(page);
- HtmlElement span = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":icon");
+ HtmlElement span = page.getHtmlElementById(menuGroup.getClientId(facesContext) +
":icon");
assertNotNull(span);
- assertEquals("span", span.getNodeName());
- List images = span.getHtmlElementsByTagName("img");
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
+ List<HtmlElement> images =
span.getHtmlElementsByTagName(HTML.IMG_ELEMENT);
assertNotNull(images);
assertEquals(1, images.size());
}
@@ -147,13 +147,12 @@
menuGroup.setDisabled(true);
menuGroup.getAttributes().put("iconDisabled",
"menuGroupIcon");
HtmlPage page = renderView();
- // System.out.println(page.asXml());
+
assertNotNull(page);
- HtmlElement span = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":icon");
- assertEquals("span", span.getNodeName());
+ HtmlElement span = page.getHtmlElementById(menuGroup.getClientId(facesContext) +
":icon");
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
assertNotNull(span);
- List images = span.getHtmlElementsByTagName("img");
+ List<HtmlElement> images =
span.getHtmlElementsByTagName(HTML.IMG_ELEMENT);
assertNotNull(images);
assertEquals(1, images.size());
}
@@ -165,10 +164,9 @@
menuGroup.getFacets().put("icon", facet);
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
- HtmlElement span = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":icon");
- assertEquals("span", span.getNodeName());
+
+ HtmlElement span = page.getHtmlElementById(menuGroup.getClientId(facesContext) +
":icon");
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
assertNotNull(span);
}
@@ -179,10 +177,9 @@
menuGroup.getFacets().put("iconDisabled", facet);
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
- HtmlElement span = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":icon");
- assertEquals("span", span.getNodeName());
+
+ HtmlElement span = page.getHtmlElementById(menuGroup.getClientId(facesContext) +
":icon");
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
assertNotNull(span);
}
@@ -190,22 +187,20 @@
menuGroup.setDisabled(true);
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
- HtmlElement span = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":icon");
+
+ HtmlElement span = page.getHtmlElementById(menuGroup.getClientId(facesContext) +
":icon");
assertNotNull(span);
- assertEquals("span", span.getNodeName());
- String classAttr = span.getAttributeValue("class");
- assertTrue(classAttr
- .contains("dr-menu-icon rich-menu-item-icon-disabled"));
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
+ String classAttr = span.getAttributeValue(HTML.class_ATTRIBUTE);
- HtmlElement div = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext));
+ HtmlElement div = page.getHtmlElementById(menuGroup.getClientId(facesContext));
assertNotNull(div);
- assertEquals("div", div.getNodeName());
- classAttr = div.getAttributeValue("class");
- assertTrue(classAttr
- .contains("dr-menu-item dr-menu-item-disabled
rich-menu-group-disabled rich-menu-group"));
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
+ classAttr = div.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("dr-menu-item"));
+ assertTrue(classAttr.contains("dr-menu-item-disabled"));
+ assertTrue(classAttr.contains("rich-menu-group-disabled"));
+ assertTrue(classAttr.contains("rich-menu-group"));
}
@@ -214,48 +209,47 @@
menuGroup.getAttributes().put("iconClass", "iconClass");
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
- HtmlElement anchor = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":anchor");
+
+ HtmlElement anchor = page.getHtmlElementById(menuGroup.getClientId(facesContext)
+ ":anchor");
assertNotNull(anchor);
- assertEquals("span", anchor.getNodeName());
- String classAttr = anchor.getAttributeValue("class");
+ assertEquals(HTML.SPAN_ELEM, anchor.getNodeName());
+ String classAttr = anchor.getAttributeValue(HTML.class_ATTRIBUTE);
assertTrue(classAttr.contains("rich-menu-item-label"));
- HtmlElement span = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":icon");
+ HtmlElement span = page.getHtmlElementById(menuGroup.getClientId(facesContext) +
":icon");
assertNotNull(span);
- assertEquals("span", span.getNodeName());
- classAttr = span.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-menu-icon rich-menu-item-icon"));
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
+ classAttr = span.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("dr-menu-icon"));
+ assertTrue(classAttr.contains("rich-menu-item-icon"));
assertTrue(classAttr.contains((String) menuGroup.getAttributes().get(
"iconClass")));
- HtmlElement div = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext));
+ HtmlElement div = page.getHtmlElementById(menuGroup.getClientId(facesContext));
assertNotNull(div);
- assertEquals("div", div.getNodeName());
- classAttr = div.getAttributeValue("class");
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
+ classAttr = div.getAttributeValue(HTML.class_ATTRIBUTE);
assertTrue(classAttr
.contains("dr-menu-item dr-menu-item-enabled
rich-menu-group"));
- div = page.getHtmlElementById("ref"
- + menuGroup.getClientId(facesContext) + ":folder");
+ div = page.getHtmlElementById(menuGroup.getClientId(facesContext) +
":folder");
assertNotNull(div);
- assertEquals("div", div.getNodeName());
- classAttr = div.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-menu-node dr-menu-node-icon
rich-menu-item-folder"));
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
+ classAttr = div.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("dr-menu-node"));
+ assertTrue(classAttr.contains("dr-menu-node-icon"));
+ assertTrue(classAttr.contains("rich-menu-item-folder"));
}
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List links =
page.getDocumentElement().getHtmlElementsByTagName("link");
- // Assert.assertEquals(1, links.size());
+ List<HtmlElement> links =
page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
+
assertNotNull(links);
- HtmlElement link = (HtmlElement) links.get(0);
- assertTrue(link.getAttributeValue("href").contains(
+ HtmlElement link = links.get(0);
+ assertTrue(link.getAttributeValue(HTML.HREF_ATTR).contains(
"menucomponents.xcss"));
}
Modified:
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
---
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -34,6 +34,7 @@
import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.event.EventsQueue;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
@@ -123,11 +124,11 @@
menuItem.setSubmitMode(MenuComponent.MODE_NONE);
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
+
HtmlElement div = page.getHtmlElementById(menuItem
.getClientId(facesContext));
assertNotNull(div);
- assertEquals("div", div.getNodeName());
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
}
/**
@@ -139,11 +140,11 @@
menuItem.getFacets().put("icon", text);
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
+
HtmlElement span = page.getHtmlElementById(menuItem
.getClientId(facesContext)
+ ":icon");
- assertEquals("span", span.getNodeName());
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
assertNotNull(span);
}
@@ -156,11 +157,11 @@
menuItem.getFacets().put("iconDisabled", text);
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
+
HtmlElement span = page.getHtmlElementById(menuItem
.getClientId(facesContext)
+ ":icon");
- assertEquals("span", span.getNodeName());
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
assertNotNull(span);
}
@@ -172,31 +173,36 @@
menuItem.getAttributes().put("iconDisabled",
"menuItemIconDisabled");
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
+
HtmlElement span = page.getHtmlElementById(menuItem
.getClientId(facesContext)
+ ":anchor");
assertNotNull(span);
- assertEquals("span", span.getNodeName());
- String classAttr = span.getAttributeValue("class");
- assertTrue(classAttr
- .contains("rich-menu-item-label
rich-menu-item-label-disabled"));
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
+ String classAttr = span.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("rich-menu-item-label"));
+ assertTrue(classAttr.contains("rich-menu-item-label-disabled"));
span = page.getHtmlElementById(menuItem.getClientId(facesContext)
+ ":icon");
assertNotNull(span);
- assertEquals("span", span.getNodeName());
- classAttr = span.getAttributeValue("class");
- assertTrue(classAttr
- .contains("dr-menu-icon rich-menu-item-icon dr-menu-icon-disabled
rich-menu-item-icon-disabled"));
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
+ classAttr = span.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("dr-menu-icon"));
+ assertTrue(classAttr.contains("rich-menu-item-icon"));
+ assertTrue(classAttr.contains("dr-menu-icon-disabled"));
+ assertTrue(classAttr.contains("rich-menu-item-icon-disabled"));
HtmlElement div = page.getHtmlElementById(menuItem
.getClientId(facesContext));
assertNotNull(div);
- assertEquals("div", div.getNodeName());
- classAttr = div.getAttributeValue("class");
- assertTrue(classAttr
- .contains("dr-menu-item dr-menu-item-disabled rich-menu-item
rich-menu-item-disabled"));
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
+ classAttr = div.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("dr-menu-item"));
+ assertTrue(classAttr.contains("dr-menu-item-disabled"));
+ assertTrue(classAttr.contains("rich-menu-item"));
+ assertTrue(classAttr.contains("rich-menu-item-disabled"));
+
classAttr = div.getAttributeValue("onmouseout");
assertEquals(0, classAttr.length());
classAttr = div.getAttributeValue("onmouseover");
@@ -214,36 +220,39 @@
menuItem.getAttributes().put("selectStyle",
"menuItemSelectStyle");
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
+
HtmlElement anchor = page.getHtmlElementById(menuItem
.getClientId(facesContext)
+ ":anchor");
assertNotNull(anchor);
- assertEquals("span", anchor.getNodeName());
- String classAttr = anchor.getAttributeValue("class");
+ assertEquals(HTML.SPAN_ELEM, anchor.getNodeName());
+ String classAttr = anchor.getAttributeValue(HTML.class_ATTRIBUTE);
assertTrue(classAttr.contains("rich-menu-item-label"));
HtmlElement span = page.getHtmlElementById(menuItem
.getClientId(facesContext)
+ ":icon");
assertNotNull(span);
- assertEquals("span", span.getNodeName());
- classAttr = span.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-menu-icon rich-menu-item-icon"));
- assertTrue(classAttr.contains((String) menuItem.getAttributes().get(
- "iconClass")));
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
+ classAttr = span.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("dr-menu-icon"));
+ assertTrue(classAttr.contains("rich-menu-item-icon"));
+
+ assertTrue(classAttr.contains((String)
menuItem.getAttributes().get("iconClass")));
- HtmlElement div = page.getHtmlElementById(menuItem
- .getClientId(facesContext));
+ HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
assertNotNull(div);
- assertEquals("div", div.getNodeName());
- classAttr = div.getAttributeValue("class");
- assertTrue(classAttr
- .contains("dr-menu-item dr-menu-item-enabled rich-menu-item
rich-menu-item-enabled"));
- classAttr = div.getAttributeValue("onclick");
- assertNotNull(classAttr);
- assertTrue(classAttr.length() > 0);
- classAttr = div.getAttributeValue("onmouseover");
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
+ classAttr = div.getAttributeValue(HTML.class_ATTRIBUTE);
+ assertTrue(classAttr.contains("dr-menu-item"));
+ assertTrue(classAttr.contains("dr-menu-item-enabled"));
+ assertTrue(classAttr.contains("rich-menu-item"));
+ assertTrue(classAttr.contains("rich-menu-item-enabled"));
+
+ String onclickAttr = div.getAttributeValue(HTML.onclick_ATTRIBUTE);
+ assertNotNull(onclickAttr);
+ assertTrue(onclickAttr.length() > 0);
+ classAttr = div.getAttributeValue(HTML.onmouseover_ATTRIBUTE);
assertTrue(classAttr.contains("menuItemSelectStyle"));
}
@@ -255,14 +264,13 @@
menuItem.getAttributes().put("style", "menuItemStyle");
HtmlPage page = renderView();
assertNotNull(page);
- //System.out.println(page.asXml());
- HtmlElement div = page.getHtmlElementById(menuItem
- .getClientId(facesContext));
+
+ HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
assertNotNull(div);
- String classAttr = div.getAttributeValue("onclick");
- assertTrue(classAttr.contains("AJAX"));
- classAttr = div.getAttributeValue("style");
- assertTrue(classAttr.contains("menuItemStyle"));
+ String onclickAttr = div.getAttributeValue(HTML.onclick_ATTRIBUTE);
+ assertTrue(onclickAttr.contains("AJAX"));
+ String styleAttr = div.getAttributeValue(HTML.style_ATTRIBUTE);
+ assertTrue(styleAttr.contains("menuItemStyle"));
}
/**
@@ -272,11 +280,10 @@
menuItem.setSubmitMode(MenuComponent.MODE_NONE);
HtmlPage page = renderView();
assertNotNull(page);
- // System.out.println(page.asXml());
- HtmlElement div = page.getHtmlElementById(menuItem
- .getClientId(facesContext));
+
+ HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
assertNotNull(div);
- String classAttr = div.getAttributeValue("onclick");
+ String classAttr = div.getAttributeValue(HTML.onclick_ATTRIBUTE);
assertNotNull(classAttr);
assertTrue(classAttr.length() > 0);
}
@@ -287,12 +294,11 @@
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List links =
page.getDocumentElement().getHtmlElementsByTagName("link");
- // assertEquals(1, links.size());
+ List<HtmlElement> links =
page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
+
assertNotNull(links);
- HtmlElement link = (HtmlElement) links.get(0);
- assertTrue(link.getAttributeValue("href").contains(
- "menucomponents.xcss"));
+ HtmlElement link = links.get(0);
+
assertTrue(link.getAttributeValue(HTML.HREF_ATTR).contains("menucomponents.xcss"));
}
/**
Modified:
trunk/ui/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
===================================================================
---
trunk/ui/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -111,9 +111,10 @@
public void testProcessInlineStylesMethod() throws Exception {
String style = "some style";
String selectStyle = "some select style";
- String result = renderer.processInlineStyles(facesContext, menuItem,
- true);
- assertEquals(result, "");
+ String result = renderer.processInlineStyles(facesContext, menuItem,true);
+
+ assertNotNull(result);
+ assertTrue(result.startsWith("$('menuItem').style.cssText="));
menuItem.getAttributes().put("selectStyle", selectStyle);
result = renderer.processInlineStyles(facesContext, menuItem, false);
Modified:
trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java
===================================================================
---
trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -10,6 +10,7 @@
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlOutputText;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.richfaces.component.html.HtmlRichMessages;
@@ -40,27 +41,6 @@
super(name);
}
- public void testRenderStyle() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- List<HtmlElement> links =
page.getDocumentElement().getHtmlElementsByTagName("link");
- assertNotNull(links);
- boolean found = false;
- for (HtmlElement link : links) {
- if
(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/msgs.css"))
{
- found = true;
- break;
- }
- }
- assertTrue(found);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- messages1 = null;
- messages2 = null;
- }
-
public void setUp() throws Exception {
super.setUp();
@@ -142,6 +122,8 @@
messages2.getFacets().put("fatalMarker", output3);
messages2.getFacets().put("infoMarker", output4);
+ messages1.setTitle("TITLE2");
+
FacesMessage facesMessage = new FacesMessage();
facesMessage.setDetail("TEST detail");
@@ -173,6 +155,27 @@
}
+ public void tearDown() throws Exception {
+ super.tearDown();
+ messages1 = null;
+ messages2 = null;
+ }
+
+ public void testRenderStyle() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ List<HtmlElement> links =
page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
+ assertNotNull(links);
+ boolean found = false;
+ for (HtmlElement link : links) {
+ if
(link.getAttributeValue(HTML.HREF_ATTR).contains("org/richfaces/renderkit/html/css/msgs.css"))
{
+ found = true;
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
public void testRendererMessage() throws Exception{
HtmlPage page = renderView();
assertNotNull(page);
@@ -183,95 +186,81 @@
assertNotNull(table);
assertNotNull(dl);
- assertEquals(table.getNodeName().toLowerCase(), "table");
- assertEquals(dl.getNodeName().toLowerCase(), "dl");
+ assertEquals(HTML.TABLE_ELEMENT, table.getNodeName());
+ assertEquals(HTML.DL_ELEMENT, dl.getNodeName());
- String classAttr = table.getAttributeValue("class");
+ String classAttr = table.getAttributeValue(HTML.class_ATTRIBUTE);
assertTrue(classAttr.contains("rich-message"));
- classAttr = dl.getAttributeValue("class");
+ classAttr = dl.getAttributeValue(HTML.class_ATTRIBUTE);
assertTrue(classAttr.contains("rich-message"));
// test rendering component mockup for list layout
- Iterator dtIter= dl.getChildElementsIterator();
+ Iterator<HtmlElement> dtIter= dl.getChildElementsIterator();
for (; dtIter.hasNext();) {
- HtmlElement dt = (HtmlElement) dtIter.next();
+ HtmlElement dt = dtIter.next();
assertNotNull(dt);
- assertEquals(dt.getNodeName().toLowerCase(), "dt");
- classAttr = dt.getAttributeValue("class");
+ assertEquals(dt.getNodeName().toLowerCase(), HTML.DT_ELEMENT);
+ classAttr = dt.getAttributeValue(HTML.class_ATTRIBUTE);
assertTrue(classAttr.contains("errorClass")||classAttr.contains("fatalClass")
||classAttr.contains("warnClass")
||classAttr.contains("infoClass"));
- Iterator spanIter= dt.getChildElementsIterator();
+ Iterator<HtmlElement> spanIter= dt.getChildElementsIterator();
for (; spanIter.hasNext();) {
- HtmlElement span = (HtmlElement) dtIter.next();
+ HtmlElement span = (HtmlElement) spanIter.next();
assertNotNull(span);
- assertEquals(dt.getNodeName().toLowerCase(), "span");
+ assertEquals(HTML.SPAN_ELEM, span.getNodeName());
- classAttr = dt.getAttributeValue("class");
+ classAttr = span.getAttributeValue(HTML.class_ATTRIBUTE);
- assertTrue(classAttr.contains("rich-messages-label") ||
classAttr.contains("rich-massages-marker"));
+ assertTrue(classAttr.contains("rich-messages-label") ||
classAttr.contains("rich-messages-marker"));
assertTrue(classAttr.contains("errorLabelClass") ||
classAttr.contains("infoLabelClass")
|| classAttr.contains("fatalLabelClass") ||
classAttr.contains("warnLabelClass")
|| classAttr.contains("errorMarkerClass") ||
classAttr.contains("fatalMarkerClass")
|| classAttr.contains("infoMarkerClass") ||
classAttr.contains("warnMarkerClass"));
-
- String title = dt.getAttributeValue("title");
-
- assertEquals("TITLTE", title);
}
}
// test rendering component mockup for table layout
- HtmlElement tbody = (HtmlElement)table.getFirstChild();
+ HtmlElement tbody = (HtmlElement)table.getFirstDomChild();
assertNotNull(tbody);
assertEquals(tbody.getNodeName().toLowerCase(), "tbody");
- Iterator trIter = tbody.getChildIterator();
+ Iterator<HtmlElement> trIter = tbody.getChildIterator();
for (;trIter.hasNext();) {
- HtmlElement tr = (HtmlElement) trIter.next();
+ HtmlElement tr = trIter.next();
assertNotNull(tr);
- assertEquals(tr.getNodeName().toLowerCase(), "tr");
+ assertEquals(tr.getNodeName().toLowerCase(), HTML.TR_ELEMENT);
- classAttr = tr.getAttributeValue("class");
-
- assertTrue(classAttr.contains("errorClass")||classAttr.contains("fatalClass")
- ||classAttr.contains("warnClass")
||classAttr.contains("infoClass"));
-
- Iterator tdIter = tr.getChildIterator();
+ Iterator<HtmlElement> tdIter = tr.getChildIterator();
for (;tdIter.hasNext();) {
- HtmlElement td = (HtmlElement)tdIter.next();
+ HtmlElement td = tdIter.next();
assertNotNull(td);
- assertEquals(td.getNodeName().toLowerCase(), "td");
+ assertEquals(td.getNodeName().toLowerCase(), HTML.td_ELEM);
- if(td.getAttributeValue("class")!= null){
- classAttr = td.getAttributeValue("class");
+ if(td.getAttributeValue(HTML.class_ATTRIBUTE)!= null){
+ classAttr = td.getAttributeValue(HTML.class_ATTRIBUTE);
- assertTrue(classAttr.contains("rich-messages-marker"));
- assertTrue(classAttr.contains("errorMarkerClass") ||
classAttr.contains("fatalMarkerClass")
- || classAttr.contains("infoMarkerClass") ||
classAttr.contains("warnMarkerClass"));
+
assertTrue(classAttr.contains("errorClass")||classAttr.contains("fatalClass")
+ ||classAttr.contains("warnClass")
||classAttr.contains("infoClass"));
}
- HtmlElement elem = (HtmlElement)td.getFirstChild();
+ HtmlElement elem = (HtmlElement)td.getFirstDomChild();
assertNotNull(elem);
- if(elem.getNodeName().equals("span")){
- classAttr = tr.getAttributeValue("class");
+ if(elem.getNodeName().equals(HTML.SPAN_ELEM)){
+ classAttr = tr.getAttributeValue(HTML.class_ATTRIBUTE);
- assertTrue(classAttr.contains("rich-messages-label"));
- assertTrue(classAttr.contains("errorLabelClass") ||
classAttr.contains("infoLabelClass")
- || classAttr.contains("fatalLabelClass") ||
classAttr.contains("warnLabelClass"));
-
- String title = elem.getAttributeValue("title");
- assertEquals("TITLTE", title);
+ String title = elem.getAttributeValue(HTML.title_ATTRIBUTE);
+ assertEquals("TITLE2", title);
}
}
}
Modified:
trunk/ui/orderingList/src/test/java/org/richfaces/renderkit/OrderingListRenderingTest.java
===================================================================
---
trunk/ui/orderingList/src/test/java/org/richfaces/renderkit/OrderingListRenderingTest.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/orderingList/src/test/java/org/richfaces/renderkit/OrderingListRenderingTest.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -33,6 +33,7 @@
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpServletResponse;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
@@ -51,8 +52,8 @@
*
*/
public class OrderingListRenderingTest extends AbstractAjax4JsfTestCase {
- private static Set javaScripts = new HashSet();
- private static Set imageClasses = new HashSet();
+ private static Set<String> javaScripts = new HashSet<String>();
+ private static Set<String> imageClasses = new HashSet<String>();
static {
javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
@@ -90,7 +91,7 @@
private UIForm form = null;
private UIOrderingList orderingList = null;
- private List items = null;
+ private List<SimpleItem> items = null;
private HtmlOutputText output1 = null;
private HtmlOutputText output2 = null;
private UIColumn column1 = null;
@@ -115,7 +116,7 @@
caption.setValue("caption");
orderingList.getFacets().put("caption", caption);
- items = new ArrayList();
+ items = new ArrayList<SimpleItem>();
items.add(new SimpleItem("Michael", 2000));
items.add(new SimpleItem("John", 500));
items.add(new SimpleItem("George", 4000));
@@ -157,16 +158,16 @@
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List scripts =
page.getDocumentElement().getHtmlElementsByTagName("script");
+ List<HtmlScript> scripts =
page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.SCRIPT_ELEM);
int foundCount = 0;
- for (Iterator it = scripts.iterator(); it.hasNext();) {
- HtmlScript item = (HtmlScript) it.next();
+ for (Iterator<HtmlScript> it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = it.next();
String srcAttr = item.getSrcAttribute();
if (StringUtils.isNotBlank(srcAttr)) {
boolean found = false;
- for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
- String src = (String) srcIt.next();
+ for (Iterator<String> srcIt = javaScripts.iterator();
srcIt.hasNext();) {
+ String src = srcIt.next();
found = srcAttr.contains(src);
if (found) {
@@ -192,8 +193,8 @@
InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
- for (Iterator it = imageClasses.iterator(); it.hasNext(); ) {
- String clazz = (String) it.next();
+ for (Iterator<String> it = imageClasses.iterator(); it.hasNext(); ) {
+ String clazz = it.next();
builder.createResource(null, clazz);
InternetResource resource = builder.getResource(clazz);
assertNotNull(resource);
@@ -218,13 +219,13 @@
public void testRenderStyle() throws Exception {
HtmlPage view = renderView();
assertNotNull(view);
- List links =
view.getDocumentElement().getHtmlElementsByTagName("link");
+ List<HtmlElement> links =
view.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
assertNotNull(links);
assertEquals(1, links.size());
- HtmlElement link = (HtmlElement) links.get(0);
-
assertTrue(link.getAttributeValue("href").contains("css/orderingList.xcss"));
+ HtmlElement link = links.get(0);
+
assertTrue(link.getAttributeValue(HTML.HREF_ATTR).contains("css/orderingList.xcss"));
- String uri = "http:" + link.getAttributeValue("href");
+ String uri = "http:" + link.getAttributeValue(HTML.HREF_ATTR);
Page page = webClient.getPage(uri);
assertNotNull(page);
assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
@@ -238,17 +239,16 @@
public void testRenderControls() throws Exception {
HtmlPage view = renderView();
assertNotNull(view);
- System.out.println(view.asXml());
- List images =
view.getDocumentElement().getHtmlElementsByTagName("img");
+ List<HtmlElement> images =
view.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.IMG_ELEMENT);
assertNotNull(images);
int generatedCount = 0;
- for (Iterator it = images.iterator(); it.hasNext(); ) {
- HtmlElement img = (HtmlElement) it.next();
+ for (Iterator<HtmlElement> it = images.iterator(); it.hasNext(); ) {
+ HtmlElement img = it.next();
assertNotNull(img);
- String uri = "http:" + img.getAttributeValue("src");
+ String uri = "http:" + img.getAttributeValue(HTML.src_ATTRIBUTE);
Page page = webClient.getPage(uri);
assertNotNull(page);
assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
@@ -258,36 +258,36 @@
}
generatedCount++;
- HtmlElement element = (HtmlElement) img.getParentNode();
+ HtmlElement element = (HtmlElement) img.getParentDomNode();
assertNotNull(element);
- assertEquals("div", element.getNodeName());
- String clazz = element.getAttributeValue("class");
+ assertEquals(HTML.DIV_ELEM, element.getNodeName());
+ String clazz = element.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz);
assertTrue("rich-ordering-list-button-content".equals(clazz));
- element = (HtmlElement) element.getParentNode();
+ element = (HtmlElement) element.getParentDomNode();
assertNotNull(element);
- assertEquals("a", element.getNodeName());
- String href = element.getAttributeValue("href");
- assertNotNull(href);
+ if (HTML.a_ELEMENT.equalsIgnoreCase(element.getNodeName())) {
+ element = (HtmlElement) element.getParentDomNode();
+ assertNotNull(element);
+ }
- element = (HtmlElement) element.getParentNode();
+ assertEquals(HTML.DIV_ELEM, element.getNodeName());
+
+ element = (HtmlElement) element.getParentDomNode();
assertNotNull(element);
- if ("a".equalsIgnoreCase(element.getNodeName())) {
- element = (HtmlElement) element.getParentNode();
- assertNotNull(element);
- }
- assertEquals("div", element.getNodeName());
- clazz = element.getAttributeValue("class");
+
+ assertEquals(HTML.DIV_ELEM, element.getNodeName());
+ clazz = element.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz);
- assertTrue(clazz.startsWith("rich-ordering-list-button"));
+ assertTrue(clazz.contains("rich-ordering-control-"));
- element = (HtmlElement) element.getParentNode();
+ element = (HtmlElement) element.getParentDomNode();
assertNotNull(element);
- assertEquals("div", element.getNodeName());
- clazz = element.getAttributeValue("class");
+ assertEquals(HTML.DIV_ELEM, element.getNodeName());
+ clazz = element.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz);
- assertTrue(clazz.contains("rich-ordering-control"));
+ assertTrue(clazz.contains("rich-ordering-list-button-layout"));
}
assertEquals(8, generatedCount);
}
@@ -303,33 +303,33 @@
HtmlElement div = view.getHtmlElementById(orderingList.getClientId(facesContext)
+ "contentBox");
assertNotNull(div);
- assertEquals("div", div.getNodeName());
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
- HtmlElement table = (HtmlElement)div.getFirstChild();
+ HtmlElement table = (HtmlElement)div.getFirstDomChild();
assertNotNull(table);
- assertEquals("table", table.getNodeName());
+ assertEquals(HTML.TABLE_ELEMENT, table.getNodeName());
- HtmlElement tbody = (HtmlElement)table.getFirstChild();
+ HtmlElement tbody = (HtmlElement)table.getFirstDomChild();
assertNotNull(tbody);
- assertEquals("tbody", tbody.getNodeName());
+ assertEquals(HTML.TBOBY_ELEMENT, tbody.getNodeName());
int rowsCount = 0;
- for (Iterator it = tbody.getChildIterator(); it.hasNext(); ) {
- HtmlElement tr = (HtmlElement)it.next();
+ for (Iterator<HtmlElement> it = tbody.getChildIterator(); it.hasNext(); )
{
+ HtmlElement tr = it.next();
assertNotNull(tr);
- assertEquals("tr", tr.getNodeName());
+ assertEquals(HTML.TR_ELEMENT, tr.getNodeName());
- String clazz = tr.getAttributeValue("class");
+ String clazz = tr.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz);
assertTrue(clazz.contains("rich-ordering-list-row"));
int cellsCount = 0;
- for (Iterator it2 = tr.getChildIterator(); it2.hasNext(); ) {
- HtmlElement td = (HtmlElement)it2.next();
+ for (Iterator<HtmlElement> it2 = tr.getChildIterator(); it2.hasNext();
) {
+ HtmlElement td = it2.next();
assertNotNull(td);
- assertEquals("td", td.getNodeName());
+ assertEquals(HTML.td_ELEM, td.getNodeName());
- String clazz2 = td.getAttributeValue("class");
+ String clazz2 = td.getAttributeValue(HTML.class_ATTRIBUTE);
assertNotNull(clazz2);
assertTrue(clazz2.contains("rich-ordering-list-cell"));
@@ -353,21 +353,22 @@
HtmlElement div =
view.getHtmlElementById(orderingList.getClientId(facesContext));
assertNotNull(div);
- assertEquals("div", div.getNodeName());
+ assertEquals(HTML.DIV_ELEM, div.getNodeName());
HtmlElement hidden1 =
view.getHtmlElementById(orderingList.getClientId(facesContext) +
"focusKeeper");
assertNotNull(hidden1);
- assertEquals("input", hidden1.getNodeName());
- assertEquals("button", hidden1.getAttributeValue("type"));
- hidden1.getAttributeValue("style").contains("left:
-32767px");
+ assertEquals(HTML.INPUT_ELEM, hidden1.getNodeName());
+ assertEquals(HTML.BUTTON, hidden1.getAttributeValue(HTML.TYPE_ATTR));
+ hidden1.getAttributeValue(HTML.style_ATTRIBUTE).contains("left:
-32767px");
- List hiddens =
view.getDocumentElement().getHtmlElementsByAttribute("input", "name",
orderingList.getClientId(facesContext));
+ List<HtmlElement> hiddens = view.getDocumentHtmlElement()
+ .getHtmlElementsByAttribute(HTML.INPUT_ELEM, HTML.NAME_ATTRIBUTE,
orderingList.getClientId(facesContext));
assertNotNull(hiddens);
assertEquals(ROWS_COUNT, hiddens.size());
- for (Iterator it = hiddens.iterator(); it.hasNext(); ) {
- HtmlElement hidden2 = (HtmlElement) it.next();
- assertEquals("input", hidden2.getNodeName());
- assertEquals("hidden", hidden2.getAttributeValue("type"));
+ for (Iterator<HtmlElement> it = hiddens.iterator(); it.hasNext(); ) {
+ HtmlElement hidden2 = it.next();
+ assertEquals(HTML.INPUT_ELEM, hidden2.getNodeName());
+ assertEquals(HTML.INPUT_TYPE_HIDDEN,
hidden2.getAttributeValue(HTML.TYPE_ATTR));
}
}
Modified:
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
---
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2008-03-26
17:09:56 UTC (rev 7268)
+++
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2008-03-26
17:10:49 UTC (rev 7269)
@@ -291,6 +291,7 @@
protected void preEncodeBegin(FacesContext context, UIComponent component) throws
IOException {
+ super.preEncodeBegin(context, component);
if(component instanceof UITabPanel){
UITabPanel tabPanel = (UITabPanel)component;
ComponentVariables componentVariables =
ComponentsVariableResolver.getVariables(this, tabPanel);
Modified: trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
===================================================================
--- trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2008-03-26 17:09:56 UTC (rev 7268)
+++ trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2008-03-26 17:10:49 UTC (rev 7269)
@@ -66,9 +66,6 @@
<f:call name="utils.encodeEndFormIfNessesary" />
</td>
</tr>
- <!-- tr>
- <td class="dr-bottom-line" width="100%"><img
src="#{spacer}" width="1" height="1" alt=""
border="0"/></td>
- </tr-->
<tr>
<vcp:body>
<f:call name="renderChildren" />