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/07/17 11:54:47 UTC
svn commit: r556867 - in /myfaces/tobago/trunk/example/test/src/main:
java/org/apache/myfaces/tobago/example/test/TestBean.java webapp/menu.jsp
Author: bommel
Date: Tue Jul 17 02:54:45 2007
New Revision: 556867
URL: http://svn.apache.org/viewvc?view=rev&rev=556867
Log:
added dynamic menubar demo
Added:
myfaces/tobago/trunk/example/test/src/main/webapp/menu.jsp
Modified:
myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/TestBean.java
Modified: myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/TestBean.java?view=diff&rev=556867&r1=556866&r2=556867
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/TestBean.java (original)
+++ myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/TestBean.java Tue Jul 17 02:54:45 2007
@@ -23,8 +23,11 @@
import org.apache.myfaces.tobago.component.UIData;
import org.apache.myfaces.tobago.component.UIColumn;
import org.apache.myfaces.tobago.component.UICommand;
+import org.apache.myfaces.tobago.component.UIMenu;
+import org.apache.myfaces.tobago.component.UIMenuCommand;
import javax.faces.component.UIOutput;
+import javax.faces.component.UIPanel;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.el.MethodBinding;
@@ -42,8 +45,6 @@
import java.io.IOException;
/*
- * Created by IntelliJ IDEA.
- * User: bommel
* Date: 18.02.2006
* Time: 11:08:45
*/
@@ -67,6 +68,33 @@
private String value;
private Date date;
private Date date1;
+ private UIMenu fileMenu;
+
+
+ public UIPanel getFileMenu() {
+ if (fileMenu == null) {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ fileMenu = (UIMenu) context.getApplication().createComponent(UIMenu.COMPONENT_TYPE);
+
+ fileMenu.getAttributes().put("label", "File");
+ }
+ if (fileMenu.getChildCount() == 0) {
+ for(int i = 0; i < 5; i++) {
+ addMenuCommand(fileMenu);
+ }
+ }
+
+ return fileMenu;
+
+ }
+
+ private void addMenuCommand(UIMenu fileMenu) {
+ UIMenuCommand command = (UIMenuCommand) FacesContext.getCurrentInstance().getApplication().createComponent(UIMenuCommand.COMPONENT_TYPE);
+ command.getAttributes().put("label", "test"+fileMenu.getChildCount());
+ // TODO setAction
+ fileMenu.getChildren().add(command);
+ }
public String layout() {
this.date1 = date;
Added: myfaces/tobago/trunk/example/test/src/main/webapp/menu.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/menu.jsp?view=auto&rev=556867
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/menu.jsp (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/menu.jsp Tue Jul 17 02:54:45 2007
@@ -0,0 +1,35 @@
+<%--
+ * 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.
+--%>
+<%@ 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" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
+
+<f:view >
+ <tc:page applicationIcon="icon/favicon.ico" id="page" width="1000px" height="700px">
+
+ <tc:box label="Menu">
+ <f:facet name="layout">
+ <tc:gridLayout rows="fixed;*"/>
+ </f:facet>
+ <tc:menuBar>
+ <tc:menu label="File" binding="#{test.fileMenu}" />
+ </tc:menuBar>
+ <tc:cell/>
+ </tc:box>
+ </tc:page>
+</f:view>