[jboss-cvs] jboss-portal/core/src/main/org/jboss/portal/core/portlet/management/actions ...

Boleslaw Dawidowicz bdaw at o2.pl
Thu Jul 27 16:40:49 EDT 2006


  User: bdaw    
  Date: 06/07/27 16:40:49

  Added:       core/src/main/org/jboss/portal/core/portlet/management/actions 
                        PropertyAction.java
  Log:
  management - portal objects properties
  
  Revision  Changes    Path
  1.1      date: 2006/07/27 20:40:49;  author: bdaw;  state: Exp;jboss-portal/core/src/main/org/jboss/portal/core/portlet/management/actions/PropertyAction.java
  
  Index: PropertyAction.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.core.portlet.management.actions;
  
  import org.jboss.portal.core.portlet.management.PortalObjectManagerBean;
  import org.jboss.portal.core.portlet.management.InstanceManagerBean;
  import org.jboss.portal.core.model.portal.PortalObject;
  import org.jboss.portal.core.model.portal.Context;
  import org.jboss.portal.core.model.portal.Portal;
  import org.jboss.portal.core.model.portal.PortalObjectPermission;
  import org.jboss.portal.security.spi.provider.DomainConfigurator;
  import org.jboss.portal.security.RoleSecurityBinding;
  import org.jboss.portal.security.SecurityConstants;
  import org.jboss.portal.theme.ThemeConstants;
  import org.jboss.logging.Logger;
  import org.apache.myfaces.component.html.ext.HtmlDataTable;
  
  import javax.faces.context.FacesContext;
  import javax.faces.component.UIComponent;
  import javax.faces.application.FacesMessage;
  import javax.faces.validator.ValidatorException;
  import javax.faces.event.ActionEvent;
  import java.util.Set;
  import java.util.HashSet;
  import java.util.Collections;
  
  /**
   * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
   * @version $Revision: 1.1 $
   */
  public class PropertyAction
  {
     private Logger log = Logger.getLogger(getClass());
  
     /**
      * .
      */
     private PortalObjectManagerBean pomgr;
  
     private HtmlDataTable propertyDataTable;
  
     private String selectedProperty;
  
     private String propertyValue;
  
     private static final String ERROR_WRONG_NAME = "Wrong property name!";
  
     private static final String ERROR_EMPTY_NAME = "Property name cannot be blank!";
  
     public PortalObjectManagerBean getPortalObjectManager()
     {
        //don't know why but this isn't injected properly in faces-config.xml
        if (pomgr == null)
        {
           FacesContext ctx = FacesContext.getCurrentInstance();
           pomgr = (PortalObjectManagerBean)ctx.getApplication().createValueBinding("#{portalobjectmgr}").getValue(ctx);
        }
        return pomgr;
     }
  
     public void setPortalObjectManager(PortalObjectManagerBean portalObjectManager)
     {
        this.pomgr = portalObjectManager;
     }
  
     public String getSelectedProperty()
     {
        return selectedProperty;
     }
  
     public void setSelectedProperty(String selectedProperty)
     {
        this.selectedProperty = selectedProperty;
     }
  
     public HtmlDataTable getPropertyDataTable()
     {
        return propertyDataTable;
     }
  
     public void setPropertyDataTable(HtmlDataTable propertyDataTable)
     {
        this.propertyDataTable = propertyDataTable;
     }
  
     public String getPropertyValue()
     {
        return propertyValue;
     }
  
     public void setPropertyValue(String propertyValue)
     {
        this.propertyValue = propertyValue;
     }
  
  
     public void validatePropertyName(FacesContext context, UIComponent toValidate, Object value)
     {
        String propertyName = (String)value;
  
        // check for empty string
        if (propertyName.startsWith(" "))
        {
           FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, PropertyAction.ERROR_EMPTY_NAME, PropertyAction.ERROR_EMPTY_NAME);
           throw new ValidatorException(message);
        }
  
     }
  
     public void selectProperty()
     {
        String[] property = (String[])getPropertyDataTable().getRowData();
        selectedProperty = property[0];
        propertyValue = property[1];
     }
  
     public void removeProperty()
     {
        String[] property = (String[])getPropertyDataTable().getRowData();
        getPortalObjectManager().getSelectedObject().setDeclaredProperty(property[0], null);
     }
  
     public void updateProperty()
     {
        getPortalObjectManager().getSelectedObject().setDeclaredProperty(getSelectedProperty(), getPropertyValue());
     }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list