
woko.facets.builtin.all.RenderPropertiesImpl Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2001-2012 Remi Vankeisbelck
*
* 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 woko.facets.builtin.all;
import net.sourceforge.jfacets.IFacetContext;
import net.sourceforge.jfacets.IFacetDescriptorManager;
import net.sourceforge.jfacets.annotations.FacetKey;
import woko.facets.BaseFragmentFacet;
import woko.facets.WokoFacetContext;
import woko.facets.builtin.RenderProperties;
import woko.facets.builtin.WokoFacets;
import woko.persistence.ObjectStore;
import woko.users.UserManager;
import woko.users.UsernameResolutionStrategy;
import woko.util.Util;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Generic renderProperties
fragment facet : renders the properties of the
* target object as HTML using Object Renderer facets.
*/
@FacetKey(name = WokoFacets.renderProperties, profileId = "all")
public class RenderPropertiesImpl<
OsType extends ObjectStore,
UmType extends UserManager,
UnsType extends UsernameResolutionStrategy,
FdmType extends IFacetDescriptorManager
> extends BaseFragmentFacet implements RenderProperties {
public static final String FRAGMENT_PATH = "/WEB-INF/woko/jsp/all/renderProperties.jsp";
public static final String FRAGMENT_PATH_FLAT = "/WEB-INF/woko/jsp/all/renderPropertiesFlatLayout.jsp";
private List propertyNames;
private Map propertyValues;
private boolean useFlatLayout = false;
public boolean isUseFlatLayout() {
return useFlatLayout;
}
public void setUseFlatLayout(boolean useFlatLayout) {
this.useFlatLayout = useFlatLayout;
}
public String getPath() {
if (useFlatLayout) {
return FRAGMENT_PATH_FLAT;
}
return FRAGMENT_PATH;
}
public List getPropertyNames() {
return propertyNames;
}
public Map getPropertyValues() {
return propertyValues;
}
public void setFacetContext(IFacetContext iFacetContext) {
super.setFacetContext(iFacetContext);
Object obj = iFacetContext.getTargetObject();
Class> objType = obj!=null ? obj.getClass() : iFacetContext.getTargetObjectClass();
propertyNames = Util.getPropertyNames(objType, Arrays.asList("metaClass"));
propertyValues = new HashMap();
if (obj!=null) {
for (String pName : propertyNames) {
propertyValues.put(pName, Util.getPropertyValue(obj, pName));
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy