portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jf...@apache.org
Subject cvs commit: jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/view pam-detail.jsp
Date Tue, 07 Sep 2004 19:59:54 GMT
jford       2004/09/07 12:59:54

  Modified:    applications/pam/src/java/org/apache/jetspeed/portlets/pam
                        PortletApplicationDetail.java
               applications/pam/src/webapp/WEB-INF/view pam-detail.jsp
  Log:
  Added support for user attributes
  
  Revision  Changes    Path
  1.6       +2 -2      jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
  
  Index: PortletApplicationDetail.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PortletApplicationDetail.java	3 Sep 2004 19:35:50 -0000	1.5
  +++ PortletApplicationDetail.java	7 Sep 2004 19:59:53 -0000	1.6
  @@ -1,9 +1,9 @@
   /*
 * Copyright 2000-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.
 */
package org.apache.jetspeed.portlets.pam;
   
  -import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import
java.util.Locale;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import
javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import
javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import
org.apache.jetspeed.portlet.ServletPortlet;
import org.apache.jetspeed.portlets.pam.beans.PortletApplicationBean;
import
org.apache.jetspeed.portlets.pam.beans.TabBean;
import org.apache.jetspeed.components.persistence.store.PersistenceStore;
import
org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
import org.apache.jetspeed.om.common.GenericMetadata;
import
org.apache.jetspeed.om.common.LocalizedField;
import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
import
org.apache.pluto.om.portlet.PortletDefinition;
/**
 * This portlet is a browser over all the
portlet applications in the system.
 *
 * @author <a href="mailto:jford@apache.com">Jeremy
Ford</a>
 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id$
 */
public class PortletApplicationDetail extends ServletPortlet
{
    private
static final String PORTLET_ACTION = "portlet_action";
    private final String VIEW_PA =
"portletApplication"; 
    private final String VIEW_PD = "portletDefinition";

    private
PortletContext context;
    private PortletRegistryComponent registry;
    private HashMap
tabMap = new HashMap();
    
    public void init(PortletConfig config)
    throws PortletException

    {
        super.init(config);
        context = getPortletContext();
        registry
= (PortletRegistryComponent)context.getAttribute(PortletApplicationResources.CPS_REGISTRY_COMPONENT);
       if (null == registry)
        {
            throw new PortletException("Failed to find
the Portlet Registry on portlet initialization");
        }
        
        TabBean tb1 =
new TabBean("Details", "Details");
        TabBean tb2 = new TabBean("Metadata", "Metadata");
       TabBean tb3 = new TabBean("Portlets", "Portlets");
        
        tabMap.put(tb1.getId(),
tb1);
        tabMap.put(tb2.getId(), tb2);
        tabMap.put(tb3.getId(), tb3);
    }
 
  
    public void doView(RenderRequest request, RenderResponse response)
  +import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import
java.util.Locale;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import
javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import
javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import
org.apache.jetspeed.portlet.ServletPortlet;
import org.apache.jetspeed.portlets.pam.beans.PortletApplicationBean;
import
org.apache.jetspeed.portlets.pam.beans.TabBean;
import org.apache.jetspeed.components.persistence.store.PersistenceStore;
import
org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
import org.apache.jetspeed.om.common.GenericMetadata;
import
org.apache.jetspeed.om.common.LocalizedField;
import org.apache.jetspeed.om.common.UserAttribute;
import
org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
import org.apache.jetspeed.om.impl.UserAttributeImpl;
import
org.apache.pluto.om.portlet.PortletDefinition;
/**
 * This portlet is a browser over all the
portlet applications in the system.
 *
 * @author <a href="mailto:jford@apache.com">Jeremy
Ford</a>
 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id$
 */
public class PortletApplicationDetail extends ServletPortlet
{
    private
static final String PORTLET_ACTION = "portlet_action";
    private final String VIEW_PA =
"portletApplication"; 
    private final String VIEW_PD = "portletDefinition";

    private
PortletContext context;
    private PortletRegistryComponent registry;
    private HashMap
tabMap = new HashMap();
    
    public void init(PortletConfig config)
    throws PortletException

    {
        super.init(config);
        context = getPortletContext();
        registry
= (PortletRegistryComponent)context.getAttribute(PortletApplicationResources.CPS_REGISTRY_COMPONENT);
       if (null == registry)
        {
            throw new PortletException("Failed to find
the Portlet Registry on portlet initialization");
        }
        
        TabBean tb1 =
new TabBean("Details", "Details");
        TabBean tb2 = new TabBean("Metadata", "Metadata");
       TabBean tb3 = new TabBean("Portlets", "Portlets");
        TabBean tb4 = new TabBean("UserAttr",
"User Attributes");
        
        tabMap.put(tb1.getId(), tb1);
        tabMap.put(tb2.getId(),
tb2);
        tabMap.put(tb3.getId(), tb3);
        tabMap.put(tb4.getId(), tb4);
    }
 
  
    public void doView(RenderRequest request, RenderResponse response)
       throws PortletException, IOException
       {
        response.setContentType("text/html");
        
        MutablePortletApplication
pa = (MutablePortletApplication)
                request.getPortletSession().getAttribute(PortletApplicationResources.PAM_CURRENT_PA,

                                                         PortletSession.APPLICATION_SCOPE);
       
        if (null != pa)
        {
            request.setAttribute(VIEW_PA, new PortletApplicationBean(pa));
           
            PortletDefinition pdef = (PortletDefinition) request.getPortletSession().getAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET,
PortletSession.APPLICATION_SCOPE);
            
            request.setAttribute(VIEW_PD,
pdef);
            
            request.setAttribute("tabs", tabMap.values());
          
 
            TabBean selectedTab = (TabBean) request.getPortletSession().getAttribute("selected_tab");
           if(selectedTab == null) {
                selectedTab = (TabBean) tabMap.values().iterator().next();
           }
            request.setAttribute("selected_tab", selectedTab);
            
       }
           super.doView(request, response);
       }
  -    
    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException, IOException
	{
        //System.out.println("PorletApplicationDetail:
processAction()");
        MutablePortletApplication pa = (MutablePortletApplication)
   
	actionRequest.getPortletSession().getAttribute(PortletApplicationResources.PAM_CURRENT_PA,

                                             PortletSession.APPLICATION_SCOPE);
        
       String selectedPortlet = actionRequest.getParameter(PortletApplicationResources.REQUEST_SELECT_PORTLET);
       if(selectedPortlet != null)
        {
	        
	        
	        PortletDefinition
pdef = pa.getPortletDefinitionByName(selectedPortlet);
	        actionRequest.getPortletSession().setAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET,
pdef, PortletSession.APPLICATION_SCOPE);
        }
        
        String selectedTab = actionRequest.getParameter("selected_tab");
       if(selectedTab != null)
        {
            TabBean tab = (TabBean) tabMap.get(selectedTab);
           actionRequest.getPortletSession().setAttribute("selected_tab", tab);
        }
       
        String action = actionRequest.getParameter(PORTLET_ACTION);
        if(action
!= null)
        {
            if(action.equals("edit_metadata"))
            {
         
      GenericMetadata md = pa.getMetadata();
                Iterator fieldsIter = md.getFields().iterator();
               
                registry.getPersistenceStore().getTransaction().begin();
               
                while (fieldsIter.hasNext())
                {
          
         LocalizedField field = (LocalizedField) fieldsIter.next();
                    String
id = field.getId().toString();
                    String value = actionRequest.getParameter(id
+ ":value");
                    if(value != null)
                    {
                
       if(!value.equals(field.getValue()))
                        {
                    
       field.setValue(value);
                        }
                    }
           
    }
                
                registry.getPersistenceStore().getTransaction().commit();
           }
            else if(action.equals("remove_metadata"))
            {
        
       GenericMetadata md = pa.getMetadata();
                Iterator fieldsIter = md.getFields().iterator();
               
                registry.getPersistenceStore().getTransaction().begin();
               while (fieldsIter.hasNext())
                {
                    LocalizedField
field = (LocalizedField) fieldsIter.next();
                    String id = field.getId().toString();
                   String[] ids = actionRequest.getParameterValues("metadata_id");
      
             if(ids != null)
                    {
                        for(int i=0; i<ids.length;
i++)
                        {
                            String mid = ids[i];
         
                  if(mid.equals(id))
                            {
                      
         fieldsIter.remove();
                            }
                        }
   
                }
                }
                registry.getPersistenceStore().getTransaction().commit();
           }
            else if(action.equals("add_metadata"))
            {
           
    GenericMetadata md = pa.getMetadata();
                
                PersistenceStore
store = registry.getPersistenceStore();
                System.out.println("Transcation is
open: " + store.getTransaction().isOpen());
                store.getTransaction().begin();
               System.out.println("Transcation is open: " + store.getTransaction().isOpen());
               String name = actionRequest.getParameter("name");
                String value
= actionRequest.getParameter("value");
                String localeParam = actionRequest.getParameter("locale");
               if(localeParam == null)
                {
                    localeParam =
"en"; //need to default better
                }
                Locale locale = new Locale(localeParam);
               
                md.addField(locale, name, value);
                
      
         store.getTransaction().commit();
            }
        }
	}
  +    
    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException, IOException
	{
        //System.out.println("PorletApplicationDetail:
processAction()");
        MutablePortletApplication pa = (MutablePortletApplication)
   
	actionRequest.getPortletSession().getAttribute(PortletApplicationResources.PAM_CURRENT_PA,

                                             PortletSession.APPLICATION_SCOPE);
        
       String selectedPortlet = actionRequest.getParameter(PortletApplicationResources.REQUEST_SELECT_PORTLET);
       if(selectedPortlet != null)
        {
	        
	        
	        PortletDefinition
pdef = pa.getPortletDefinitionByName(selectedPortlet);
	        actionRequest.getPortletSession().setAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET,
pdef, PortletSession.APPLICATION_SCOPE);
        }
        
        String selectedTab = actionRequest.getParameter("selected_tab");
       if(selectedTab != null)
        {
            TabBean tab = (TabBean) tabMap.get(selectedTab);
           actionRequest.getPortletSession().setAttribute("selected_tab", tab);
        }
       
        String action = actionRequest.getParameter(PORTLET_ACTION);
        if(action
!= null)
        {
            if(action.endsWith("metadata"))
            {
            
   processMetadataAction(actionRequest, actionResponse, pa, action);
            }
      
     else if(action.endsWith("user_attribute"))
            {
                processUserAttributeAction(actionRequest,
actionResponse, pa, action);
            }
        }
	}
    
    /**
     * @param actionRequest
    * @param actionResponse
     * @param pa
     * @param action
     */
    private void
processUserAttributeAction(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication
pa, String action) throws PortletException, IOException
    {
        if(action.equals("edit_user_attribute"))
       {
            registry.getPersistenceStore().getTransaction().begin();
           

            Iterator userAttrIter = pa.getUserAttributes().iterator();
            while
(userAttrIter.hasNext())
            {
                UserAttribute userAttr = (UserAttribute)
userAttrIter.next();
                
                String userAttrName = userAttr.getName();
               String description = actionRequest.getParameter(userAttrName + ":description");
               if(!userAttr.getDescription().equals(description))
                {
     
              userAttr.setDescription(description);
                }
            }
     
      
            registry.getPersistenceStore().getTransaction().commit();
        }
  
     else if(action.equals("add_user_attribute"))
        {
            String userAttrName
= actionRequest.getParameter("user_attr_name");
            String userAttrDesc = actionRequest.getParameter("user_attr_desc");
           if(userAttrName != null)
            {
                registry.getPersistenceStore().getTransaction().begin();
           
                //TODO: should this come from a factory??
                UserAttribute
userAttribute = new UserAttributeImpl();
                userAttribute.setName(userAttrName);
               userAttribute.setDescription(userAttrDesc);
                pa.addUserAttribute(userAttribute);
            
	            registry.getPersistenceStore().getTransaction().commit();
     
      }
        }
        else if(action.equals("remove_user_attribute"))
        {
     
      String[] userAttrNames = actionRequest.getParameterValues("user_attr_id");

       
    if(userAttrNames != null)
            {
                registry.getPersistenceStore().getTransaction().begin();
                               
	            Iterator userAttrIter = pa.getUserAttributes().iterator();
            while (userAttrIter.hasNext())
	            {
	                UserAttribute userAttr
= (UserAttribute) userAttrIter.next();
	                for(int i=0; i<userAttrNames.length;
i++)
	                {
	                    String userAttrName = userAttrNames[i];
	   
                if(userAttr.getName().equals(userAttrName))
	                    {
	     
                  userAttrIter.remove();
	                        break;
	               
    }
	                }
	            }
	            
	            registry.getPersistenceStore().getTransaction().commit();
               
            }
        }
    }

    /**
     * @param actionRequest
     *
@param actionResponse
     * @param pa
     * @param action
     * @throws PortletException
    * @throws IOException
     */
    private void processMetadataAction(ActionRequest actionRequest,
ActionResponse actionResponse, MutablePortletApplication pa, String action) throws PortletException,
IOException
    {
        if(action.equals("edit_metadata"))
        {
            GenericMetadata
md = pa.getMetadata();
            Iterator fieldsIter = md.getFields().iterator();
     
      
            registry.getPersistenceStore().getTransaction().begin();
            
           while (fieldsIter.hasNext())
            {
                LocalizedField field
= (LocalizedField) fieldsIter.next();
                String id = field.getId().toString();
               String value = actionRequest.getParameter(id + ":value");
                if(value
!= null)
                {
                    if(!value.equals(field.getValue()))
      
             {
                        field.setValue(value);
                    }
     
          }
            }
            
            registry.getPersistenceStore().getTransaction().commit();
       }
        else if(action.equals("remove_metadata"))
        {
            GenericMetadata
md = pa.getMetadata();
            Iterator fieldsIter = md.getFields().iterator();
     
      String[] ids = actionRequest.getParameterValues("metadata_id");
            
      
     if(ids != null)
            {
	            registry.getPersistenceStore().getTransaction().begin();
            while (fieldsIter.hasNext())
	            {
	                LocalizedField field
= (LocalizedField) fieldsIter.next();
	                String id = field.getId().toString();

                   for(int i=0; i<ids.length; i++)
                    {
             
          String mid = ids[i];
                        if(mid.equals(id))
               
        {
                            fieldsIter.remove();
                            break;
                       }
                    }
                }
            }
          
 registry.getPersistenceStore().getTransaction().commit();
        }
        else if(action.equals("add_metadata"))
       {
            GenericMetadata md = pa.getMetadata();
            
            PersistenceStore
store = registry.getPersistenceStore();
            System.out.println("Transcation is open:
" + store.getTransaction().isOpen());
            store.getTransaction().begin();
       
    System.out.println("Transcation is open: " + store.getTransaction().isOpen());
      
     String name = actionRequest.getParameter("name");
            String value = actionRequest.getParameter("value");
           String localeParam = actionRequest.getParameter("locale");
            if(localeParam
== null)
            {
                localeParam = "en"; //need to default better
     
      }
            Locale locale = new Locale(localeParam);
            
            md.addField(locale,
name, value);
            
            store.getTransaction().commit();
        }
    }
   }
  
  
  
  1.6       +1 -1      jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/view/pam-detail.jsp
  
  Index: pam-detail.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/view/pam-detail.jsp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- pam-detail.jsp	3 Sep 2004 19:35:21 -0000	1.5
  +++ pam-detail.jsp	7 Sep 2004 19:59:54 -0000	1.6
  @@ -1 +1 @@
  -<%--
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.
--%>
<%@ page language="java" import="javax.portlet.*, java.util.*,
org.apache.jetspeed.portlets.pam.PortletApplicationBean, org.apache.jetspeed.portlets.pam.beans.TabBean,
org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite" session="true" %>
<%@
taglib uri='/WEB-INF/portlet.tld' prefix='portlet'%>
<%@ taglib uri="http://java.sun.com/jstl/core"
prefix="c" %>


<portlet:defineObjects/>
<h2>Portlet Application Detail</h2>

<c:set
var="pa" value="${requestScope.portletApplication}" />
<c:set var="name" value="${pa.name}"
/>
<c:set var="version" value="${pa.version}" />

<c:set var="tabs" value="${requestScope.tabs}"/>
<c:set
var="selectedTab" value="${requestScope.selected_tab}"/>
<c:set var="selectedPDef" value="${requestScope.portletDefinition}"/>

app.name
= <c:out value="${name}"/><br />
app.version = <c:out value="${version}"/>

<p>TODO:
Details</p>
<div id="tabs">
	<table border="0" cellpadding="0" cellspacing="0"
width="100%">
	  <tr>
		<c:forEach var="tab" items="${tabs}">
			<td <c:if
test="${tab == selectedTab}"> class="LTabLeft" </c:if>
			    <c:if test="${tab
!= selectedTab}"> class="LTabLeftLow" </c:if>
			     style="font-size:1pt;" nowrap="true">
		     &nbsp;
			</td>
	        	<td <c:if test="${tab == selectedTab}">
class="LTab" </c:if>
	                <c:if test="${tab != selectedTab}"> class="LTabLow"
</c:if>
                     align="center" valign="middle" nowrap="true">
     
               
                     <% String tabid = ((TabBean)pageContext.getAttribute("tab")).getId();
%>
                     <portlet:actionURL var="select_tab_link" >
             
           <portlet:param name="selected_tab" value="<%= tabid %>" />
       
             </portlet:actionURL>
                     
                    <a href="<c:out
value="${select_tab_link}"/>">
                        <c:out value="${tab.description}"/>
                   </a>
                </td>
                <td <c:if
test="${tab == selectedTab}"> class="LTabRight" </c:if>
                    <c:if
test="${tab != selectedTab}"> class="LTabRightLow" </c:if> 
                    style="font-size:1pt;"
nowrap="true">
                    &nbsp;
                </td>
            </c:forEach>
       </tr>
      </table>
</div>

<%--Beginning of Portlets tab data--%>
<%--TODO:
 switch to c:choose --%>
<c:if test="${selectedTab.id == 'Portlets'}">
  <div
id="portlets">
	
	<portlet:actionURL var="select_portlet_link" >
        <%--<portlet:param
name="select_portlet" value="<%= pdefName %>" />--%>
    </portlet:actionURL>
<form action="<c:out value="${select_portlet_link}"/>">
		<select name="select_portlet">
	<c:forEach var="portletDef" items="${pa.portletDefinitions}">
		    <c:set var="pdefName"
value="${portletDef.name}"/>
		    
		    <%--We must do this since portlet taglib doesn't
support expressions--%>
		    <% String pdefName = (String) pageContext.getAttribute("pdefName");
%>
		    
		    <option value="<c:out value="${portletDef.name}"/>" <c:if test="${selectedPDef.name
== portletDef.name}">selected="true"</c:if>>
			  <c:out value="${portletDef.name}"/>
	    </option>
			<%--
		    <a href="<c:out value="${select_portlet_link}"/>">
	        <c:out value="${portletDef.name}" /><br />
		    </a>
		    --%>
	</c:forEach>
		</select>
		
		<input type="submit" value="Select"/>
  
 </form>
  </div>
    
  <div id="selectedPortlet" class="">
    <span
class="portlet-section-header">Selected Portlet</span>
    <c:out value="${selectedPDef.name}"/>
 </div>
</c:if>
<%--End of Portlets tab data--%>

<%--Beginning of Metadata
tab data--%>
<%--TODO:  switch to c:choose --%>
<c:if test="${selectedTab.id ==
'Metadata'}">
	<div id="metadata">
		<script type="text/javascript">
			
	
</script>
	
	
		<c:set var="md" value="${pa.metadata}"/>
		
		<%
			//pageContext.getAttribute("md").getClass().getName()
	%>
		
		<portlet:actionURL var="edit_metadata_link" >
			
		</portlet:actionURL>
	
		<form name="Edit_Metatdata_Form" action="<c:out value="${edit_metadata_link}"/>">
	<input type="hidden" name="portlet_action" value="edit_metadata"/>
		<c:forEach
var="field" items="${md.fields}">
		
			<input type="checkbox" name="metadata_id" value="<c:out
value="${field.id}"/>"/>
			
			<c:out value="${field.name}"/> | <c:out value="${field.value}"/>
| <c:out value="${field.locale}"/> 
			<%--TODO:  value needs to escaped, or use
textarea--%>
			
			<input type="text" name="<c:out value="${field.id}"/>:value"
value="<c:out value="${field.value}"/>"/>
				
			<br />	
		</c:forEach>
	
		<input type="submit" value="Edit" onClick="this.form.portlet_action.value = 'edit_metadata'"/>
	<input type="submit" value="Remove Selected" onClick="this.form.portlet_action.value =
'remove_metadata'"/>
		</form>
		
		<form action="<c:out value="${edit_metadata_link}"/>">
		<input type="hidden" name="portlet_action" value="add_metadata"/>
			
			Name: <input
type="text" name="name" value=""/> <br />
			Value: <input type="text" name="value"
value=""/> <br />
			Locale: <input type="text" name="locale" value=""/> <br
/>
			<input type="submit" value="Add Metadata"/>
		</form>
	</div>
</c:if>
<%--End
of Metadata tab data--%>

<br />
<br />


  \ No newline at end of file
  +<%--
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.
--%>
<%@ page language="java" import="javax.portlet.*, java.util.*,
org.apache.jetspeed.portlets.pam.PortletApplicationBean, org.apache.jetspeed.portlets.pam.beans.TabBean,
org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite" session="true" %>
<%@
taglib uri='/WEB-INF/portlet.tld' prefix='portlet'%>
<%@ taglib uri="http://java.sun.com/jstl/core"
prefix="c" %>


<portlet:defineObjects/>
<h2>Portlet Application Detail</h2>

<c:set
var="pa" value="${requestScope.portletApplication}" />
<c:set var="name" value="${pa.name}"
/>
<c:set var="version" value="${pa.version}" />

<c:set var="tabs" value="${requestScope.tabs}"/>
<c:set
var="selectedTab" value="${requestScope.selected_tab}"/>
<c:set var="selectedPDef" value="${requestScope.portletDefinition}"/>

app.name
= <c:out value="${name}"/><br />
app.version = <c:out value="${version}"/>
<br />

<%--
app.description = <c:out value="${pa.description}"/> <br />

<c:choose>
<c:when test="${pa.applicationType == '0'}">
		app.type = WEBAPP <br />
	</c:when>
<c:when test="${pa.applicationType == '1'}">
		app.type = LOCAL <br />
	</c:when>
</c:choose>

app.id
= <c:out value="${pa.applicationIdentifier}"/>
--%>

<div id="tabs">
	<table
border="0" cellpadding="0" cellspacing="0" width="100%">
	  <tr>
		<c:forEach
var="tab" items="${tabs}">
			<td <c:if test="${tab == selectedTab}"> class="LTabLeft"
</c:if>
			    <c:if test="${tab != selectedTab}"> class="LTabLeftLow" </c:if>
		     style="font-size:1pt;" nowrap="true">
			     &nbsp;
			</td>
	      
 	<td <c:if test="${tab == selectedTab}"> class="LTab" </c:if>
	          
     <c:if test="${tab != selectedTab}"> class="LTabLow" </c:if>
            
        align="center" valign="middle" nowrap="true">
                     
          
          <% String tabid = ((TabBean)pageContext.getAttribute("tab")).getId(); %>
                    <portlet:actionURL var="select_tab_link" >
                    
    <portlet:param name="selected_tab" value="<%= tabid %>" />
              
      </portlet:actionURL>
                     
                    <a href="<c:out
value="${select_tab_link}"/>">
                        <c:out value="${tab.description}"/>
                   </a>
                </td>
                <td <c:if
test="${tab == selectedTab}"> class="LTabRight" </c:if>
                    <c:if
test="${tab != selectedTab}"> class="LTabRightLow" </c:if> 
                    style="font-size:1pt;"
nowrap="true">
                    &nbsp;
                </td>
            </c:forEach>
       </tr>
      </table>
</div>

<%--Beginning of Portlets tab data--%>
<%--TODO:
 switch to c:choose --%>
<c:if test="${selectedTab.id == 'Portlets'}">
  <div
id="portlets">
	
	<portlet:actionURL var="select_portlet_link" >
        <%--<portlet:param
name="select_portlet" value="<%= pdefName %>" />--%>
    </portlet:actionURL>
<form action="<c:out value="${select_portlet_link}"/>">
		<select name="select_portlet">
	
			<option value="" <c:if test="! ${selectedPDef}"> selected="true"</c:if>
		>Please Choose Portlet</option>
		
		<c:forEach var="portletDef" items="${pa.portletDefinitions}">
	    <c:set var="pdefName" value="${portletDef.name}"/>
		    
		    <%--We must
do this since portlet taglib doesn't support expressions--%>
		    <% String pdefName
= (String) pageContext.getAttribute("pdefName"); %>
		    
		    <option value="<c:out
value="${portletDef.name}"/>" <c:if test="${selectedPDef.name == portletDef.name}">selected="true"</c:if>>
		  <c:out value="${portletDef.name}"/>
		    </option>
			<%--
		    <a
href="<c:out value="${select_portlet_link}"/>">
		        <c:out value="${portletDef.name}"
/><br />
		    </a>
		    --%>
		</c:forEach>
		</select>
	

		<input type="submit" value="Select"/>
    </form>
  </div>
    
  <div
id="selectedPortlet" class="">
    
    <span class="portlet-section-header">Selected
Portlet</span>
	<c:out value="${selectedPDef.name}"/>
   
	<%--
    <%@
include file="portlet-detail.jsp" %>
    --%>
    
  </div>
</c:if>
<%--End
of Portlets tab data--%>

<%--Beginning of UserAttr tab data--%>
<%--TODO:  switch
to c:choose --%>
<c:if test="${selectedTab.id == 'UserAttr'}">
  <div id="Details">
<portlet:actionURL var="edit_user_attr_link" >
	</portlet:actionURL>
		
	<form
name="Edit_UserAttr_Form" action="<c:out value="${edit_user_attr_link}"/>">
		<input
type="hidden" name="portlet_action" value="edit_user_attribute"/>
		<c:forEach var="userAttr"
items="${pa.userAttributes}">
			<%--<input type="hidden" name="user_attr_name" value="<c:out
value="${userAttr.name}"/>"/>--%>
			
			<input type="checkbox" name="user_attr_id"
value="<c:out value="${userAttr.name}"/>"/>
			<c:out value="${userAttr.name}"/>
| 
			<input type="text" name="<c:out value="${userAttr.name}"/>:description" value="<c:out
value="${userAttr.description}"/>"/> <br />
		</c:forEach>
		
		<input
type="submit" value="Edit" onClick="this.form.portlet_action.value = 'edit_user_attribute'"/>
	<input type="submit" value="Remove Selected" onClick="this.form.portlet_action.value =
'remove_user_attribute'"/>
	</form>
	
	<form action="<c:out value="${edit_user_attr_link}"/>">
		<input type="hidden" name="portlet_action" value="add_user_attribute"/>
			
			Name:
<input type="text" name="user_attr_name" value=""/> <br />
			Description: <input
type="text" name="user_attr_desc" value=""/> <br />
			<input type="submit" value="Add
User Attr"/>
		</form>
  </div>
</c:if>
<%--End of UserAttr tab data--%>


<%--Beginning
of Metadata tab data--%>
<%--TODO:  switch to c:choose --%>
<c:if test="${selectedTab.id
== 'Metadata'}">
	<div id="metadata">
		<script type="text/javascript">
		

		</script>
	
	
		<c:set var="md" value="${pa.metadata}"/>
		
		<%
			//pageContext.getAttribute("md").getClass().getName()
	%>
		
		<portlet:actionURL var="edit_metadata_link" >
			
		</portlet:actionURL>
	
		<form name="Edit_Metatdata_Form" action="<c:out value="${edit_metadata_link}"/>">
	<input type="hidden" name="portlet_action" value="edit_metadata"/>
		<c:forEach
var="field" items="${md.fields}">
		
			<input type="checkbox" name="metadata_id" value="<c:out
value="${field.id}"/>"/>
			
			<c:out value="${field.name}"/> | <c:out value="${field.value}"/>
| <c:out value="${field.locale}"/> 
			<%--TODO:  value needs to escaped, or use
textarea--%>
			
			<input type="text" name="<c:out value="${field.id}"/>:value"
value="<c:out value="${field.value}"/>"/>
				
			<br />	
		</c:forEach>
	
		<input type="submit" value="Edit" onClick="this.form.portlet_action.value = 'edit_metadata'"/>
	<input type="submit" value="Remove Selected" onClick="this.form.portlet_action.value =
'remove_metadata'"/>
		</form>
		
		<form action="<c:out value="${edit_metadata_link}"/>">
		<input type="hidden" name="portlet_action" value="add_metadata"/>
			
			Name: <input
type="text" name="name" value=""/> <br />
			Value: <input type="text" name="value"
value=""/> <br />
			Locale: <input type="text" name="locale" value=""/> <br
/>
			<input type="submit" value="Add Metadata"/>
		</form>
	</div>
</c:if>
<%--End
of Metadata tab data--%>

<%--Beginning of Details tab data--%>
<%--TODO:  switch
to c:choose --%>
<c:if test="${selectedTab.id == 'Details'}">
	<div id="details">
	app.name = <c:out value="${name}"/><br />
		app.version = <c:out value="${version}"/>
<br />
		app.description = <c:out value="${pa.description}"/> <br />

	
<c:choose>
			<c:when test="${pa.applicationType == '0'}">
				app.type = WEBAPP
<br />
			</c:when>
			<c:when test="${pa.applicationType == '1'}">
			
app.type = LOCAL <br />
			</c:when>
		</c:choose>

		app.id = <c:out
value="${pa.applicationIdentifier}"/>
	
	
		<%--Name | AppId | Id <br />--%>
	<hr />
		Jetspeed Services
		<hr />
		<c:forEach var="service" items="${pa.jetspeedServices}">
		<c:out value="${service.name}"/> <br /> <%--| <c:out value="${service.appId}"/>
| <c:out value="${service.id}"/><br />--%>
		</c:forEach>
	</div>
</c:if>
<%--End
of Details tab data--%>

<br />
<br />


  \ No newline at end of file
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message