/* * 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. */ package org.apache.tuscany.geronimoace; import javax.portlet.*; import java.io.IOException; public class GeronimoACE extends GenericPortlet { private String viewUrl = "/pages/Home.jsp"; // viewUrl is set to the home page by default boolean isHome = true; // used for navigating back to the home page. public void init(PortletConfig config) throws PortletException { super.init(config); } public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { isHome = true; String task = request.getParameter("task"); // getting request parameters task and domain name String domain = request.getParameter("domainName"); if (task != null) { if (task.equals("composites")) { // if the request is for Composites,forwarding to Composites.html viewUrl = "/pages/Composite.html"; } if (task.equals("workspace")) { // if the request is for Contributions,forwarding to workspace.html viewUrl = "/pages/Workspace.html"; } if (task.equals("cloud")) { // if the request is for Clouds,forwarding to Cloud.html viewUrl = "/pages/Cloud.html"; } if (task.equals("files")) { // iif the request is for Files,forwarding to Files.html viewUrl = "/pages/Files.html"; } } response.setPortletMode(PortletMode.VIEW); // by changing portlet mode, doview methos is called again. } public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { // Set the response to read HTML response.setContentType("text/html;charset=UTF-8"); if (isHome) { // dispatching to the appropriate page PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(viewUrl); dispatcher.include(request, response); isHome = false; } else { // dispatching to the home page. PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/pages/Home.jsp"); dispatcher.include(request, response); isHome = true; } } }