You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/05/29 15:10:27 UTC
svn commit: r779952 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/taglib/component/
example/demo/src/main/webapp/reference/
theme/scarborough/src/main/java/org/apache/my...
Author: lofwyr
Date: Fri May 29 13:10:26 2009
New Revision: 779952
URL: http://svn.apache.org/viewvc?rev=779952&view=rev
Log:
TOBAGO-754: confirmation attribute in <tc:message>
Added:
myfaces/tobago/trunk/example/demo/src/main/webapp/reference/messages-confirmation.jsp
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.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/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml
myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago_de.properties.xml
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java?rev=779952&r1=779951&r2=779952&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java Fri May 29 13:10:26 2009
@@ -310,4 +310,7 @@
}
// LAYOUT End
+ public abstract Integer getWidth();
+
+ public abstract Integer getHeight();
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java?rev=779952&r1=779951&r2=779952&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/MessagesTagDeclaration.java Fri May 29 13:10:26 2009
@@ -107,4 +107,15 @@
defaultValue = AbstractUIMessages.OrderBy.OCCURENCE_STRING,
defaultCode = "org.apache.myfaces.tobago.component.AbstractUIMessages.OrderBy.OCCURENCE")
void setOrderBy(String orderBy);
+
+ /**
+ * Has the user to confirm this message?
+ * This attributes handles the case, if the application wants to warn the user about a problem,
+ * and the user has to confirm the message before he/she can continue.
+ * The default is false.
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "false")
+ void setConfirmation(String confirmation);
+
}
Added: myfaces/tobago/trunk/example/demo/src/main/webapp/reference/messages-confirmation.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/reference/messages-confirmation.jsp?rev=779952&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/reference/messages-confirmation.jsp (added)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/reference/messages-confirmation.jsp Fri May 29 13:10:26 2009
@@ -0,0 +1,87 @@
+<%--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+--%>
+<%@ page import="javax.faces.application.FacesMessage" %>
+<%@ page import="javax.faces.context.FacesContext" %>
+
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>
+
+<%
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage("message1", new FacesMessage(FacesMessage.SEVERITY_INFO, "Info message.", "Example of an info message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Warn message.", "Example of a warn message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error message.", "Example of an error message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal message.", "Example of a fatal message."));
+ facesContext.addMessage(null, new FacesMessage("Message without a severity.", "Example of a message without a severity."));
+%>
+
+<layout:overview>
+ <jsp:body>
+ <tc:box label="Messages must be confirmed here">
+ <f:facet name="layout">
+ <tc:gridLayout/>
+ </f:facet>
+
+ <tc:messages id="mymessages" confirmation="true"/>
+
+ </tc:box>
+ </jsp:body>
+</layout:overview>
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?rev=779952&r1=779951&r2=779952&view=diff
==============================================================================
--- 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 Fri May 29 13:10:26 2009
@@ -24,8 +24,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.component.AbstractUIPage;
import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.component.CreateComponentUtils;
+import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.component.UIBox;
+import org.apache.myfaces.tobago.component.UIButtonCommand;
+import org.apache.myfaces.tobago.component.UICell;
+import org.apache.myfaces.tobago.component.UICommand;
+import org.apache.myfaces.tobago.component.UIGridLayout;
import org.apache.myfaces.tobago.component.UIMessages;
+import org.apache.myfaces.tobago.component.UIPanel;
+import org.apache.myfaces.tobago.component.UIPopup;
+import org.apache.myfaces.tobago.context.ResourceManagerUtil;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
import org.apache.myfaces.tobago.renderkit.MessageRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -40,11 +53,15 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.Map;
public class MessagesRenderer extends MessageRendererBase {
private static final Log LOG = LogFactory.getLog(MessagesRenderer.class);
+ public static final String CLOSE_POPUP = "closePopup";
+
+ @Override
public int getFixedHeight(FacesContext facesContext, UIComponent component) {
int count = 0;
for (Iterator i = facesContext.getMessages(); i.hasNext(); i.next()) {
@@ -59,10 +76,16 @@
: getConfiguredValue(facesContext, component, "fixedHeight");
}
+ @Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
UIMessages messages = (UIMessages) component;
+ if (messages.isConfirmation()) {
+ createPopup(facesContext, messages);
+ return;
+ }
+
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
if (LOG.isDebugEnabled()) {
@@ -104,6 +127,74 @@
}
}
+ private void createPopup(FacesContext facesContext, UIMessages messages) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("POPUP");
+ }
+ String id = messages.getId() != null ? messages.getId() + "popup" : facesContext.getViewRoot().createUniqueId();
+ final UIPopup popup = (UIPopup)
+ CreateComponentUtils.createComponent(facesContext, UIPopup.COMPONENT_TYPE, RendererTypes.POPUP, id);
+ popup.getAttributes().put(Attributes.Z_INDEX, 10);
+
+ AbstractUIPage page = ComponentUtil.findPage(facesContext, messages);
+
+ popup.setWidth(page.getWidth() - 200);
+ popup.setHeight(page.getHeight() - 200);
+ popup.setLeft(100);
+ popup.setTop(100);
+ popup.setRendered(true);
+ popup.setActivated(true);
+ ((TobagoFacesContext) facesContext).getPopups().add(popup);
+
+ Map<String, Object> okButtonAttributes = popup.getAttributes();
+ okButtonAttributes.put(Attributes.POPUP_RESET, Boolean.TRUE);
+
+ final UIComponent box = CreateComponentUtils.createComponent(
+ facesContext, UIBox.COMPONENT_TYPE, RendererTypes.BOX);
+ popup.getChildren().add(box);
+ box.setId("box");
+ // TODO: set string resources in renderer
+ box.getAttributes().put(Attributes.LABEL, ResourceManagerUtil.getPropertyNotNull(
+ facesContext, "tobago", "tobago.message.confirmation.title"));
+ UIComponent layout = CreateComponentUtils.createComponent(
+ facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "layout");
+ box.getFacets().put(Facets.LAYOUT, layout);
+ layout.getAttributes().put(Attributes.ROWS, "*;fixed");
+ layout.getAttributes().put(Attributes.MARGIN, "10");
+
+ final UICell scrollPanel = (UICell)
+ CreateComponentUtils.createComponent(facesContext, UICell.COMPONENT_TYPE, "Cell", "messagePanel");
+ box.getChildren().add(scrollPanel);
+
+ messages.getParent().getChildren().remove(messages);
+ messages.setConfirmation(false);
+ scrollPanel.setScrollbars("auto");
+ scrollPanel.getChildren().add(messages);
+
+ UIComponent buttonPanel = CreateComponentUtils.createComponent(
+ facesContext, UIPanel.COMPONENT_TYPE, RendererTypes.PANEL, "buttonPanel");
+ layout = CreateComponentUtils.createComponent(
+ facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "buttonPanelLayout");
+ buttonPanel.getFacets().put(Facets.LAYOUT, layout);
+ layout.getAttributes().put(Attributes.COLUMNS, "*;100px");
+ layout.getAttributes().put(Attributes.ROWS, "fixed");
+
+ box.getChildren().add(buttonPanel);
+
+ final UICell space = (UICell)
+ CreateComponentUtils.createComponent(facesContext, UICell.COMPONENT_TYPE, "Cell", "space");
+ buttonPanel.getChildren().add(space);
+
+ final UICommand okButton = (UICommand) CreateComponentUtils.createComponent(
+ facesContext, UIButtonCommand.COMPONENT_TYPE, RendererTypes.BUTTON, CLOSE_POPUP);
+ buttonPanel.getChildren().add(okButton);
+ okButtonAttributes = okButton.getAttributes();
+ okButtonAttributes.put(Attributes.LABEL, ResourceManagerUtil.getPropertyNotNull(
+ facesContext, "tobago", "tobago.message.confirmation.okay"));
+ okButtonAttributes.put("popupClose", "immediate");
+ return;
+ }
+
/*
private void encodeMessagesForId(FacesContext facesContext,
TobagoResponseWriter writer, String clientId, boolean showSummary, boolean showDetail) throws IOException {
@@ -151,4 +242,3 @@
}
}
-
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml?rev=779952&r1=779951&r2=779952&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml Fri May 29 13:10:26 2009
@@ -69,6 +69,10 @@
<entry key="datePickerOk">OK</entry>
<entry key="datePickerCancel">Cancel</entry>
+ <!-- messages -->
+ <entry key="tobago.message.confirmation.title">Messages</entry>
+ <entry key="tobago.message.confirmation.okay">OK</entry>
+
<!-- requiredvalidator -->
<entry key="tobago.requiredvalidator.message.empty.summary">Required field.</entry>
<entry key="tobago.requiredvalidator.message.empty.detail">Field is required.</entry>
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago_de.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago_de.properties.xml?rev=779952&r1=779951&r2=779952&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago_de.properties.xml (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago_de.properties.xml Fri May 29 13:10:26 2009
@@ -71,6 +71,9 @@
<entry key="datePickerOk">OK</entry>
<entry key="datePickerCancel">Abbrechen</entry>
+ <!-- messages -->
+ <entry key="tobago.message.confirmation.title">Meldungen</entry>
+
<!-- requiredvalidator -->
<entry key="tobago.requiredvalidator.message.empty.summary">Pflichtfeld</entry>
<entry key="tobago.requiredvalidator.message.empty.detail">Feld benötigt eine Eingabe!</entry>