incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1139763 [8/10] - in /incubator/isis/trunk/viewer: json/ json/applib2/ json/applib2/src/ json/applib2/src/main/ json/applib2/src/main/java/ json/applib2/src/main/java/META-INF/ json/applib2/src/main/java/org/ json/applib2/src/main/java/org/...
Date Sun, 26 Jun 2011 11:51:10 GMT
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/ObjectResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/ObjectResourceImpl.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/ObjectResourceImpl.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/ObjectResourceImpl.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,602 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.WebApplicationException;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.restful.applib.resources.ObjectResource;
+import org.apache.isis.viewer.restful.viewer.Constants;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.html.XhtmlTemplate;
+import org.apache.isis.viewer.restful.viewer.resources.ResourceAbstract;
+import org.apache.isis.viewer.restful.viewer.resources.objects.actions.TableColumnNakedObjectActionInvoke;
+import org.apache.isis.viewer.restful.viewer.resources.objects.actions.TableColumnNakedObjectActionName;
+import org.apache.isis.viewer.restful.viewer.resources.objects.actions.TableColumnNakedObjectActionParamCount;
+import org.apache.isis.viewer.restful.viewer.resources.objects.actions.TableColumnNakedObjectActionRealTarget;
+import org.apache.isis.viewer.restful.viewer.resources.objects.actions.TableColumnNakedObjectActionReturnType;
+import org.apache.isis.viewer.restful.viewer.resources.objects.actions.TableColumnNakedObjectActionType;
+import org.apache.isis.viewer.restful.viewer.resources.objects.collections.TableColumnOneToManyAssociationAccess;
+import org.apache.isis.viewer.restful.viewer.resources.objects.collections.TableColumnOneToManyAssociationAddTo;
+import org.apache.isis.viewer.restful.viewer.resources.objects.collections.TableColumnOneToManyAssociationInvalidReason;
+import org.apache.isis.viewer.restful.viewer.resources.objects.collections.TableColumnOneToManyAssociationName;
+import org.apache.isis.viewer.restful.viewer.resources.objects.collections.TableColumnOneToManyAssociationRemoveFrom;
+import org.apache.isis.viewer.restful.viewer.resources.objects.properties.TableColumnOneToOneAssociationAccess;
+import org.apache.isis.viewer.restful.viewer.resources.objects.properties.TableColumnOneToOneAssociationClear;
+import org.apache.isis.viewer.restful.viewer.resources.objects.properties.TableColumnOneToOneAssociationInvalidReason;
+import org.apache.isis.viewer.restful.viewer.resources.objects.properties.TableColumnOneToOneAssociationModify;
+import org.apache.isis.viewer.restful.viewer.resources.objects.properties.TableColumnOneToOneAssociationName;
+import org.apache.isis.viewer.restful.viewer.resources.objects.properties.TableColumnOneToOneAssociationParseable;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.util.ActionUtils;
+import org.apache.isis.viewer.restful.viewer.util.InputStreamUtil;
+import org.apache.isis.viewer.restful.viewer.util.ListUtils;
+import org.apache.isis.viewer.restful.viewer.util.UrlDecoderUtils;
+import org.apache.isis.viewer.restful.viewer.xom.TableColumn;
+
+/**
+ * Implementation note: it seems to be necessary to annotate the implementation with {@link Path} rather than the
+ * interface (at least under RestEasy 1.0.2 and 1.1-RC2).
+ */
+@Path("/object")
+public class ObjectResourceImpl extends ResourceAbstract implements ObjectResource {
+
+    @Override
+    public String object(final String oidEncodedStr) {
+        init();
+        final String oidStr = UrlDecoderUtils.urlDecode(oidEncodedStr);
+
+        final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        if (objectAdapter == null) {
+            throw new WebApplicationException(responseOfGone("could not determine object"));
+        }
+
+        final String javascriptFile =
+            isJavascriptDebug() ? Constants.JQUERY_SRC_JS : Constants.JQUERY_MIN_JS;
+        // html template
+        final XhtmlTemplate xhtml =
+            new XhtmlTemplate(objectAdapter.titleString(), getServletRequest(), javascriptFile,
+                Constants.ISIS_REST_SUPPORT_JS);
+
+        xhtml.appendToBody(asDivIsisSession());
+        xhtml.appendToBody(resourcesDiv());
+
+        // object div
+        final Element objectDiv = div(HtmlClass.OBJECT);
+        xhtml.appendToBody(objectDiv);
+
+        // title & Oid
+        final Element objectSpecsDiv = asDivTableObjectDetails(objectAdapter);
+        xhtml.appendToDiv(objectDiv, objectSpecsDiv);
+        // xhtml.appendToBody(div);
+
+        // properties (in line table)
+        final Element propertiesTableEl = asDivTableProperties(getSession(), objectAdapter);
+        xhtml.appendToDiv(objectDiv, propertiesTableEl);
+        // xhtml.appendToBody(propertiesTableEl);
+
+        // collections
+        final Element collectionsDivEl = asDivTableCollections(getSession(), objectAdapter);
+        xhtml.appendToDiv(objectDiv, collectionsDivEl);
+        // xhtml.appendToBody(collectionsDivEl);
+
+        // actions
+        final Element actionsDivEl = asDivTableActions(getSession(), objectAdapter);
+        xhtml.appendToDiv(objectDiv, actionsDivEl);
+        // xhtml.appendToBody(actionsDivEl);
+
+        return xhtml.toXML();
+    }
+
+    public Element asDivTableProperties(final AuthenticationSession session, final ObjectAdapter nakedObject) {
+        final Element div = xhtmlRenderer.div_p("Properties", HtmlClass.PROPERTIES);
+
+        final ObjectSpecification noSpec = nakedObject.getSpecification();
+        final List<OneToOneAssociation> rows = noSpec.getProperties();
+
+        final List<TableColumn<OneToOneAssociation>> columns = new ArrayList<TableColumn<OneToOneAssociation>>();
+        columns.add(new TableColumnOneToOneAssociationName(noSpec, session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectAssociationType<OneToOneAssociation>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberHidden<OneToOneAssociation>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnOneToOneAssociationAccess(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberDisabled<OneToOneAssociation>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberDisabledReason<OneToOneAssociation>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnOneToOneAssociationParseable(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnOneToOneAssociationModify(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnOneToOneAssociationClear(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnOneToOneAssociationInvalidReason(session, nakedObject, getResourceContext()));
+
+        final Element table = xhtmlRenderer.table(columns, rows, HtmlClass.FACETS);
+        div.appendChild(table);
+        return div;
+    }
+
+    public Element asDivTableCollections(final AuthenticationSession session, final ObjectAdapter nakedObject) {
+        final Element div = xhtmlRenderer.div_p("Collections", HtmlClass.COLLECTIONS);
+
+        final ObjectSpecification noSpec = nakedObject.getSpecification();
+        final List<OneToManyAssociation> rows = noSpec.getCollections();
+
+        final List<TableColumn<OneToManyAssociation>> columns = new ArrayList<TableColumn<OneToManyAssociation>>();
+        columns.add(new TableColumnOneToManyAssociationName(noSpec, session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectAssociationType<OneToManyAssociation>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberHidden<OneToManyAssociation>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberDisabled<OneToManyAssociation>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnOneToManyAssociationAccess(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnOneToManyAssociationAddTo(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnOneToManyAssociationRemoveFrom(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnOneToManyAssociationInvalidReason(session, nakedObject, getResourceContext()));
+
+        final Element table = xhtmlRenderer.table(columns, rows, HtmlClass.FACETS);
+        div.appendChild(table);
+        return div;
+    }
+
+    private Element asDivTableActions(final AuthenticationSession session, final ObjectAdapter nakedObject) {
+
+        final Element div = xhtmlRenderer.div_p("Actions", HtmlClass.ACTIONS);
+        final ObjectSpecification noSpec = nakedObject.getSpecification();
+
+        final List<ObjectAction> actions = new ArrayList<ObjectAction>();
+        for (final ActionType type : ResourceAbstract.ACTION_TYPES) {
+            final List<ObjectAction> actionsForType = ActionUtils.flattened(noSpec.getObjectActions(type));
+            actions.addAll(actionsForType);
+        }
+        final List<ObjectAction> rows = ListUtils.toList(actions.toArray(new ObjectAction[0]));
+
+        final List<TableColumn<ObjectAction>> columns = new ArrayList<TableColumn<ObjectAction>>();
+        columns.add(new TableColumnNakedObjectActionName(noSpec, session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectActionType(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectActionReturnType(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectActionParamCount(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberHidden<ObjectAction>(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberDisabled<ObjectAction>(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectMemberDisabledReason<ObjectAction>(session, nakedObject,
+            getResourceContext()));
+        columns.add(new TableColumnNakedObjectActionRealTarget(session, nakedObject, getResourceContext()));
+        columns.add(new TableColumnNakedObjectActionInvoke(session, nakedObject, getResourceContext()));
+
+        final Element table = xhtmlRenderer.table(columns, rows, HtmlClass.FACETS);
+        div.appendChild(table);
+        return div;
+    }
+
+    // /////////////////////////////////////////////////////////////////////
+    // properties
+    // /////////////////////////////////////////////////////////////////////
+
+    @Override
+    public String modifyProperty(final String oidEncodedStr, final String propertyEncodedId,
+        final String proposedEncodedValue) {
+        init();
+        final String oidStr = UrlDecoderUtils.urlDecode(oidEncodedStr);
+        final String propertyId = UrlDecoderUtils.urlDecode(propertyEncodedId);
+        final String proposedValue = UrlDecoderUtils.urlDecode(proposedEncodedValue);
+
+        final ObjectAdapter nakedObject = getObjectAdapter(oidStr);
+        if (nakedObject == null) {
+            throw new WebApplicationException(responseOfGone("could not determine object"));
+        }
+
+        final ObjectSpecification noSpec = nakedObject.getSpecification();
+
+        final OneToOneAssociation property = (OneToOneAssociation) noSpec.getAssociation(propertyId);
+
+        final ObjectAdapter proposedValueNO = getObjectAdapter(proposedValue, nakedObject, property);
+
+        // make sure we have a value (should be using clear otherwise)
+        if (proposedValueNO == null) {
+            throw new WebApplicationException(responseOfBadRequest("null argument"));
+        }
+
+        // validate
+        final Consent consent = property.isAssociationValid(nakedObject, proposedValueNO);
+        if (consent.isVetoed()) {
+            throw new WebApplicationException(responseOfBadRequest(consent));
+        }
+
+        // html template
+        final XhtmlTemplate xhtml =
+            new XhtmlTemplate(nakedObject.titleString() + "." + propertyId, getServletRequest());
+        xhtml.appendToBody(asDivIsisSession());
+        xhtml.appendToBody(resourcesDiv());
+
+        // title & Oid
+        final Element div = asDivTableObjectDetails(nakedObject);
+        xhtml.appendToBody(div);
+
+        // if valid, then set
+        property.setAssociation(nakedObject, proposedValueNO);
+
+        return xhtml.toXML();
+    }
+
+    @Override
+    public String clearProperty(final String oidEncodedStr, final String propertyEncodedId) {
+        init();
+        final String oidStr = UrlDecoderUtils.urlDecode(oidEncodedStr);
+        final String propertyId = UrlDecoderUtils.urlDecode(propertyEncodedId);
+
+        final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        if (objectAdapter == null) {
+            throw new WebApplicationException(responseOfGone("could not determine object"));
+        }
+
+        final ObjectSpecification noSpec = objectAdapter.getSpecification();
+
+        final OneToOneAssociation property = (OneToOneAssociation) noSpec.getAssociation(propertyId);
+
+        // validate
+        final Consent consent = property.isAssociationValid(objectAdapter, null);
+        if (consent.isVetoed()) {
+            throw new WebApplicationException(responseOfBadRequest(consent));
+        }
+
+        // html template
+        final XhtmlTemplate xhtml =
+            new XhtmlTemplate(objectAdapter.titleString() + "." + propertyId, getServletRequest());
+        xhtml.appendToBody(asDivIsisSession());
+        xhtml.appendToBody(resourcesDiv());
+
+        // title & Oid
+        final Element div = asDivTableObjectDetails(objectAdapter);
+        xhtml.appendToBody(div);
+
+        // if valid, then clear
+        property.clearAssociation(objectAdapter);
+
+        return xhtml.toXML();
+    }
+
+    // /////////////////////////////////////////////////////////////////////
+    // collections
+    // /////////////////////////////////////////////////////////////////////
+
+    private enum CollectionModificationType {
+        ADD_TO, REMOVE_FROM
+    }
+
+    @Override
+    public String accessCollection(final String oidEncodedStr, final String collectionEncodedId) {
+        init();
+        final String oidStr = UrlDecoderUtils.urlDecode(oidEncodedStr);
+        final String collectionId = UrlDecoderUtils.urlDecode(collectionEncodedId);
+
+        final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        if (objectAdapter == null) {
+            throw new WebApplicationException(responseOfGone("could not determine object"));
+        }
+
+        final ObjectSpecification noSpec = objectAdapter.getSpecification();
+        final ObjectAssociation association = noSpec.getAssociation(collectionId);
+        if (!association.isOneToManyAssociation()) {
+            throw new WebApplicationException(responseOfBadRequest("Not a collection"));
+        }
+
+        // html template
+        final XhtmlTemplate xhtml =
+            new XhtmlTemplate(objectAdapter.titleString() + "." + collectionId, getServletRequest());
+        xhtml.appendToBody(asDivIsisSession());
+        xhtml.appendToBody(resourcesDiv());
+
+        // title & Oid
+        Element div = asDivTableObjectDetails(objectAdapter);
+        xhtml.appendToBody(div);
+
+        // collection name & contents
+        final OneToManyAssociation collection = (OneToManyAssociation) association;
+
+        div = xhtmlRenderer.div_p(collectionId, HtmlClass.COLLECTION);
+
+        final Element ul = xhtmlRenderer.ul(HtmlClass.COLLECTION);
+        div.appendChild(ul);
+
+        final ObjectAdapter collectionObj = collection.get(objectAdapter);
+
+        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionObj);
+        for (final Iterator<ObjectAdapter> iter = facet.iterator(collectionObj); iter.hasNext();) {
+            final ObjectAdapter associatedNO = iter.next();
+            ul.appendChild(toLiAHref(associatedNO));
+        }
+
+        xhtml.appendToBody(div);
+        return xhtml.toXML();
+    }
+
+    @Override
+    public String addToCollection(final String oidStr, final String collectionEncodedId,
+        final String proposedValueEncodedOidStr) {
+        return modifyCollection(oidStr, collectionEncodedId, proposedValueEncodedOidStr,
+            CollectionModificationType.ADD_TO);
+    }
+
+    @Override
+    public String removeFromCollection(final String oidStr, final String collectionEncodedId,
+        final String proposedValueEncodedOidStr) {
+        return modifyCollection(oidStr, collectionEncodedId, proposedValueEncodedOidStr,
+            CollectionModificationType.REMOVE_FROM);
+    }
+
+    private String modifyCollection(final String oidEncodedStr, final String collectionEncodedId,
+        final String proposedValueEncodedOidStr, final CollectionModificationType modification) {
+        init();
+        final String oidStr = UrlDecoderUtils.urlDecode(oidEncodedStr);
+        final String collectionId = UrlDecoderUtils.urlDecode(collectionEncodedId);
+        final String proposedValueOidStr = UrlDecoderUtils.urlDecode(proposedValueEncodedOidStr);
+
+        final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        if (objectAdapter == null) {
+            throw new WebApplicationException(responseOfGone("could not determine object"));
+        }
+
+        final ObjectSpecification noSpec = objectAdapter.getSpecification();
+
+        final OneToManyAssociation collection = (OneToManyAssociation) noSpec.getAssociation(collectionId);
+
+        ObjectAdapter proposedValueNO = null;
+        proposedValueNO = getObjectAdapter(proposedValueOidStr);
+
+        if (proposedValueNO == null) {
+            throw new WebApplicationException(responseOfGone("could not determine proposed value"));
+        }
+
+        // validate
+        final Consent consent =
+            modification == CollectionModificationType.ADD_TO ? collection.isValidToAdd(objectAdapter, proposedValueNO)
+                : collection.isValidToRemove(objectAdapter, proposedValueNO);
+        if (consent.isVetoed()) {
+            throw new WebApplicationException(responseOfBadRequest(consent));
+        }
+
+        // html template
+        final XhtmlTemplate xhtml =
+            new XhtmlTemplate(objectAdapter.titleString() + "." + collectionId, getServletRequest());
+        xhtml.appendToBody(asDivIsisSession());
+        xhtml.appendToBody(resourcesDiv());
+
+        // title & Oid
+        final Element div = asDivTableObjectDetails(objectAdapter);
+        xhtml.appendToBody(div);
+
+        // if valid, then set
+        if (modification == CollectionModificationType.ADD_TO) {
+            collection.addElement(objectAdapter, proposedValueNO);
+        } else {
+            collection.removeElement(objectAdapter, proposedValueNO);
+        }
+
+        return xhtml.toXML();
+    }
+
+    // /////////////////////////////////////////////////////////////////////
+    // actions
+    // /////////////////////////////////////////////////////////////////////
+
+    @Override
+    public String invokeAction(final String oidEncodedStr, final String actionEncodedId, final InputStream body) {
+        init();
+
+        final String oidStr = UrlDecoderUtils.urlDecode(oidEncodedStr);
+        final String actionId = UrlDecoderUtils.urlDecode(actionEncodedId);
+        final List<String> argsEncodedArray = InputStreamUtil.getArgs(body);
+        final String[] argsEncoded = argsEncodedArray.toArray(new String[] {});
+        final String[] args = urlDecode(argsEncoded);
+
+        final ObjectAdapter nakedObject = getObjectAdapter(oidStr);
+        if (nakedObject == null) {
+            throw new WebApplicationException(responseOfGone("could not determine object"));
+        }
+
+        final ObjectSpecification noSpec = nakedObject.getSpecification();
+        final ObjectAction action = getObjectAction(noSpec, actionId);
+
+        final List<ObjectActionParameter> parameters = action.getParameters();
+        final int parameterCount = parameters.size();
+        final int argumentCount = args.length;
+        if (parameterCount > argumentCount) {
+            // this isn't an != check because JAX-RS will always give us 10 args, but some/all will be null.
+            final String reason =
+                MessageFormat.format("provided {0} parameters but {1} arguments", parameterCount, argumentCount);
+            throw new WebApplicationException(responseOfBadRequest(reason));
+        }
+
+        final ObjectAdapter[] proposedArguments = new ObjectAdapter[parameterCount];
+        for (int i = 0; i < parameters.size(); i++) {
+            final String proposedArg = args[i];
+            if (proposedArg != null) {
+                final ObjectAdapter argNO = getObjectAdapter(proposedArg, nakedObject, parameters.get(i));
+
+                if (argNO == null) {
+                    throw new WebApplicationException(responseOfGone("could not determine proposed value"));
+                }
+                proposedArguments[i] = argNO;
+            }
+        }
+
+        // html template
+        final XhtmlTemplate xhtml = new XhtmlTemplate(nakedObject.titleString() + "." + actionId, getServletRequest());
+        xhtml.appendToBody(asDivIsisSession());
+
+        // title & Oid
+        Element div = asDivTableObjectDetails(nakedObject);
+        xhtml.appendToBody(div);
+
+        // action Name
+        div = xhtmlRenderer.div_p(actionId, HtmlClass.COLLECTION);
+        xhtml.appendToBody(div);
+
+        // TODO: should be checking if enabled, or indeed, if visible?
+        // probably for modifying properties and collections too.
+
+        // validate
+        final Consent consent = action.isProposedArgumentSetValid(nakedObject, proposedArguments);
+        if (consent.isVetoed()) {
+            throw new WebApplicationException(responseOfBadRequest(consent));
+        }
+
+        // invoke the action
+        final ActionInvocationFacet actionInvocationFacet = action.getFacet(ActionInvocationFacet.class);
+        final ObjectAdapter result = actionInvocationFacet.invoke(nakedObject, proposedArguments);
+        if (result == null) {
+            // do nothing;
+            // NB: this is not a response of NO_CONTENT
+            // (not sure if it ought to be, can't see how you would return it)
+        } else {
+            final Object object = result.getObject();
+            xhtml.appendToBody(actionResult(object));
+        }
+
+        return xhtml.toXML();
+    }
+
+    private static String[] urlDecode(final String[] encodedStrings) {
+        final String[] strings = new String[encodedStrings.length];
+        for (int i = 0; i < encodedStrings.length; i++) {
+            strings[i] = UrlDecoderUtils.urlDecode(encodedStrings[i]);
+        }
+        return strings;
+    }
+
+    // TODO: this is horrid - shouldn't have to search in this way...
+    private ObjectAction getObjectAction(final ObjectSpecification noSpec, final String actionId) {
+        ObjectAction action = null;
+        action = noSpec.getObjectAction(ActionType.USER, actionId);
+        if (action != null) {
+            return action;
+        }
+        action = noSpec.getObjectAction(ActionType.EXPLORATION, actionId);
+        if (action != null) {
+            return action;
+        }
+        action = noSpec.getObjectAction(ActionType.DEBUG, actionId);
+        if (action != null) {
+            return action;
+        }
+        return null;
+    }
+
+    private Element actionResult(final Object result) {
+        final Element div_p = xhtmlRenderer.div_p("Action Results", HtmlClass.ACTION_RESULT);
+        div_p.appendChild(actionResultContent(result));
+        return div_p;
+    }
+
+    private Element actionResultContent(final Object result) {
+        if (result == null) {
+            return xhtmlRenderer.p(null, HtmlClass.ACTION_RESULT);
+        }
+
+        // deal with as collection
+        if (result instanceof Collection<?>) {
+            final Collection<?> collection = (Collection<?>) result;
+            final Element ul = xhtmlRenderer.ul(HtmlClass.ACTION_RESULT);
+            for (final Object object : collection) {
+                ul.appendChild(toLiAHref(object));
+            }
+            return ul;
+        }
+
+        // deal with as object
+        return toAHref(result);
+    }
+
+    // //////////////////////////////////////////////////////////////
+    // Helpers
+    // //////////////////////////////////////////////////////////////
+
+    private Element toLiAHref(final Object object) {
+        final Element li = new Element("li");
+        li.appendChild(toAHref(object));
+        return li;
+    }
+
+    private Element toLiAHref(final ObjectAdapter nakedObject) {
+        final Element li = new Element("li");
+        li.appendChild(toAHref(nakedObject));
+        return li;
+    }
+
+    private Element toAHref(final Object object) {
+        final ObjectAdapter nakedObject = getAdapterManager().getAdapterFor(object);
+        return toAHref(nakedObject);
+    }
+
+    private Element toAHref(final ObjectAdapter nakedObject) {
+        final String uri =
+            MessageFormat.format("{0}/object/{1}", getServletRequest().getContextPath(), getOidStr(nakedObject));
+        return xhtmlRenderer.aHref(uri, nakedObject.titleString(), "object", "results", HtmlClass.ACTION_RESULT);
+    }
+
+    private ObjectAdapter getObjectAdapter(final String proposedValue, final ObjectAdapter nakedObject,
+        final ObjectFeature nakedObjectFeature) {
+        ObjectAdapter proposedValueNO = null;
+        ParseableFacet parseable = nakedObjectFeature.getFacet(ParseableFacet.class);
+        if (parseable == null) {
+            parseable = nakedObjectFeature.getSpecification().getFacet(ParseableFacet.class);
+        }
+
+        if (parseable != null) {
+            proposedValueNO = parseable.parseTextEntry(nakedObject, proposedValue);
+        } else {
+            final String proposedValueOidStr = proposedValue;
+            proposedValueNO = getObjectAdapter(proposedValueOidStr);
+        }
+        return proposedValueNO;
+    }
+
+    private boolean isJavascriptDebug() {
+        return getConfiguration().getBoolean(Constants.JAVASCRIPT_DEBUG_KEY, true);
+    }
+
+    protected IsisConfiguration getConfiguration() {
+        return IsisContext.getConfiguration();
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociation.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociation.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociation.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,34 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public abstract class TableColumnNakedObjectAssociation<T extends ObjectAssociation> extends
+    TableColumnNakedObjectMember<T> {
+
+    protected TableColumnNakedObjectAssociation(final String headerText, final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super(headerText, session, nakedObject, resourceContext);
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationModifyAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationModifyAbstract.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationModifyAbstract.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationModifyAbstract.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,119 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.restful.viewer.tree.Attribute;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public abstract class TableColumnNakedObjectAssociationModifyAbstract<T extends ObjectAssociation> extends
+    TableColumnNakedObjectAssociation<T> {
+
+    private final boolean inputField;
+
+    public TableColumnNakedObjectAssociationModifyAbstract(final String columnName,
+        final AuthenticationSession session, final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        this(columnName, session, nakedObject, resourceContext, true);
+    }
+
+    /**
+     * @param field
+     *            - whether to include an input field.
+     */
+    public TableColumnNakedObjectAssociationModifyAbstract(final String columnName,
+        final AuthenticationSession session, final ObjectAdapter nakedObject, final ResourceContext resourceContext,
+        final boolean field) {
+        super(columnName, session, nakedObject, resourceContext);
+        this.inputField = field;
+    }
+
+    @Override
+    public Element doTd(final T association) {
+        if (!association.isVisible(getSession(), getNakedObject()).isAllowed()) {
+            return xhtmlRenderer.p(null, getHtmlClassAttribute());
+        }
+        if (!association.isUsable(getSession(), getNakedObject()).isAllowed()) {
+            return xhtmlRenderer.p(null, getHtmlClassAttribute());
+        }
+
+        final Element div = xhtmlRenderer.div(getHtmlClassAttribute());
+
+        div.appendChild(form(association));
+        return div;
+    }
+
+    private Element form(final T association) {
+        final String associationId = association.getId();
+        final String formName = getFormNamePrefix() + associationId;
+        final Element form = xhtmlRenderer.form(formName, getHtmlClassAttribute());
+        form.addAttribute(new Attribute("class", associationId));
+
+        final String inputFieldName = "proposedValue";
+        if (inputField) {
+            final Element inputValue = new Element("input");
+            inputValue.addAttribute(new Attribute("type", "value"));
+            inputValue.addAttribute(new Attribute("name", inputFieldName));
+            form.appendChild(inputValue);
+        }
+
+        final Element inputButton = new Element("input");
+        inputButton.addAttribute(new Attribute("type", "button"));
+        inputButton.addAttribute(new Attribute("value", getFormButtonLabel()));
+        final String servletContextName = getContextPath();
+        final String url = MessageFormat.format("{0}/object/{1}", servletContextName, getOidStr());
+        inputButton.addAttribute(new Attribute("onclick", invokeJavascript(url, associationId, inputFieldName)));
+
+        form.appendChild(inputButton);
+        form.addAttribute(new Attribute("action", url));
+
+        return form;
+    }
+
+    protected abstract String getFormButtonLabel();
+
+    /**
+     * Used to construct the <tt>&lt;form name=&quot;xxx&quot;&gt;</tt> that holds the value used to make the change.
+     * 
+     * @return
+     */
+    protected abstract String getFormNamePrefix();
+
+    /**
+     * Used HTML Class attribute used variously throughout the rendered HTML form.
+     * 
+     * @return
+     */
+    protected abstract String getHtmlClassAttribute();
+
+    /**
+     * Invoke the appropriate Javascript function from <tt>isis-rest-support.js</tt>.
+     * 
+     * @param url
+     * @param associationId
+     * @param inputFieldName
+     * @return
+     */
+    protected abstract String invokeJavascript(String url, String associationId, String inputFieldName);
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationType.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationType.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectAssociationType.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,44 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectAssociationType<T extends ObjectAssociation> extends
+    TableColumnNakedObjectAssociation<T> {
+
+    public TableColumnNakedObjectAssociationType(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Type", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final T association) {
+        final String assocTypeFullName = association.getSpecification().getFullIdentifier();
+        final String uri = MessageFormat.format("{0}/specs/{1}", getContextPath(), assocTypeFullName);
+        return xhtmlRenderer.aHref(uri, assocTypeFullName, "propertyTypeSpec", "property", HtmlClass.PROPERTY);
+    }
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMember.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMember.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMember.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMember.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,51 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+import org.apache.isis.viewer.restful.viewer.xom.TableColumnAbstract;
+
+public abstract class TableColumnNakedObjectMember<T extends ObjectMember> extends TableColumnAbstract<T> {
+
+    private final ObjectAdapter nakedObject;
+    private final AuthenticationSession session;
+
+    protected TableColumnNakedObjectMember(final String headerText, final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super(headerText, resourceContext);
+        this.nakedObject = nakedObject;
+        this.session = session;
+    }
+
+    protected String getOidStr() {
+        return getOidStr(getNakedObject());
+    }
+
+    public ObjectAdapter getNakedObject() {
+        return nakedObject;
+    }
+
+    public AuthenticationSession getSession() {
+        return session;
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabled.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabled.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabled.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabled.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,40 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectMemberDisabled<T extends ObjectMember> extends TableColumnNakedObjectMember<T> {
+
+    public TableColumnNakedObjectMemberDisabled(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Disabled", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final T member) {
+        final boolean disabled = !member.isUsable(getSession(), getNakedObject()).isAllowed();
+        return xhtmlRenderer.p(disabled, HtmlClass.USABLE);
+    }
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabledReason.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabledReason.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabledReason.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberDisabledReason.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,46 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectMemberDisabledReason<T extends ObjectMember> extends
+    TableColumnNakedObjectMember<T> {
+
+    public TableColumnNakedObjectMemberDisabledReason(final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super("Disabled Reason", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final T property) {
+        final Consent usable = property.isUsable(getSession(), getNakedObject());
+        if (usable.isAllowed()) {
+            return xhtmlRenderer.p(null, null);
+        }
+
+        return xhtmlRenderer.p(usable.getReason(), HtmlClass.USABLE);
+    }
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberHidden.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberHidden.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberHidden.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberHidden.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,40 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectMemberHidden<T extends ObjectMember> extends TableColumnNakedObjectMember<T> {
+
+    public TableColumnNakedObjectMemberHidden(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Hidden", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final T member) {
+        final boolean hidden = !member.isVisible(getSession(), getNakedObject()).isAllowed();
+        return xhtmlRenderer.p(hidden, HtmlClass.VISIBLE);
+    }
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberInvalidReason.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberInvalidReason.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberInvalidReason.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberInvalidReason.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,47 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public abstract class TableColumnNakedObjectMemberInvalidReason<T extends ObjectMember> extends
+    TableColumnNakedObjectMember<T> {
+
+    public TableColumnNakedObjectMemberInvalidReason(final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super("Invalid Reason", session, nakedObject, resourceContext);
+    }
+
+    /**
+     * Creates a &lt;p id=&quot;association-invalid-<i>associationId</i>&quot;/&gt; element so that Javascript code can
+     * populate during validation.
+     */
+    @Override
+    public Element doTd(final T member) {
+        return builder().el("p").classAttr(HtmlClass.VALID).idAttr(getDomId(member)).build();
+    }
+
+    protected abstract String getDomId(T member);
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberName.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberName.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberName.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/TableColumnNakedObjectMemberName.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,40 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public abstract class TableColumnNakedObjectMemberName<T extends ObjectMember> extends TableColumnNakedObjectMember<T> {
+    private final ObjectSpecification noSpec;
+
+    public TableColumnNakedObjectMemberName(final ObjectSpecification noSpec, final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super("Name", session, nakedObject, resourceContext);
+        this.noSpec = noSpec;
+    }
+
+    protected ObjectSpecification getNoSpec() {
+        return noSpec;
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectAction.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectAction.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectAction.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectAction.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,39 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.restful.viewer.resources.objects.TableColumnNakedObjectMember;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public abstract class TableColumnNakedObjectAction extends TableColumnNakedObjectMember<ObjectAction> {
+
+    TableColumnNakedObjectAction(final String headerText, final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super(headerText, session, nakedObject, resourceContext);
+    }
+
+    protected final String getOidStrRealTarget(final ObjectAction action) {
+        final ObjectAdapter realTarget = action.realTarget(getNakedObject());
+        return getOidStr(realTarget);
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvalidReason.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvalidReason.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvalidReason.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvalidReason.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,40 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.restful.viewer.resources.objects.TableColumnNakedObjectMemberInvalidReason;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectActionInvalidReason extends
+    TableColumnNakedObjectMemberInvalidReason<ObjectAction> {
+
+    public TableColumnNakedObjectActionInvalidReason(final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super(session, nakedObject, resourceContext);
+    }
+
+    @Override
+    protected String getDomId(final ObjectAction action) {
+        return "action-invalid-" + action.getId();
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvoke.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvoke.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvoke.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionInvoke.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,96 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Attribute;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectActionInvoke extends TableColumnNakedObjectAction {
+
+    private final static String INPUT_FIELD_NAME_PREFIX = "arg";
+
+    public TableColumnNakedObjectActionInvoke(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Invoke", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final ObjectAction action) {
+        final Identifier actionIdentifier = action.getIdentifier();
+        final String actionId = actionIdentifier.toNameParmsIdentityString();
+
+        final String formName = "action-" + actionId;
+        final String uri =
+            MessageFormat.format("{0}/object/{1}/action/{2}", resourceContext.getHttpServletRequest().getContextPath(),
+                getOidStrRealTarget(action), actionId);
+        final List<ObjectActionParameter> parameters = action.getParameters();
+
+        final Element div = xhtmlRenderer.div(HtmlClass.ACTION);
+        div.appendChild(renderForm(formName, uri, parameters));
+        return div;
+    }
+
+    private Element renderForm(final String formName, final String uri, final List<ObjectActionParameter> parameters) {
+
+        final Element form = xhtmlRenderer.form(formName, HtmlClass.ACTION);
+        form.addAttribute(new Attribute("method", "POST"));
+        form.addAttribute(new Attribute("action", uri));
+
+        renderInputFieldsForParameters(parameters, form);
+
+        renderInputButton(form);
+
+        return form;
+    }
+
+    private void renderInputFieldsForParameters(final List<ObjectActionParameter> parameters, final Element form) {
+        for (int i = 0; i < parameters.size(); i++) {
+            final ObjectActionParameter parameter = parameters.get(i);
+            final String inputFieldName = INPUT_FIELD_NAME_PREFIX + i;
+
+            final Element inputLabel = new Element("p");
+            inputLabel.appendChild(parameter.getName());
+            form.appendChild(inputLabel);
+
+            final Element inputValue = new Element("input");
+            inputValue.addAttribute(new Attribute("type", "value"));
+            inputValue.addAttribute(new Attribute("name", inputFieldName));
+            inputValue.addAttribute(new Attribute("class", parameter.getName()));
+            form.appendChild(inputValue);
+        }
+    }
+
+    private void renderInputButton(final Element form) {
+        final Element inputButton = new Element("input");
+        inputButton.addAttribute(new Attribute("type", "submit"));
+        inputButton.addAttribute(new Attribute("value", "Invoke"));
+        form.appendChild(inputButton);
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionName.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionName.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionName.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionName.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,50 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.resources.objects.TableColumnNakedObjectMemberName;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public class TableColumnNakedObjectActionName extends TableColumnNakedObjectMemberName<ObjectAction> {
+
+    public TableColumnNakedObjectActionName(final ObjectSpecification noSpec, final AuthenticationSession session,
+        final ObjectAdapter nakedObject, final ResourceContext resourceContext) {
+        super(noSpec, session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final ObjectAction nakedObjectAction) {
+        final String actionId = nakedObjectAction.getIdentifier().toNameParmsIdentityString();
+        final String memberType = "action";
+        final String uri =
+            MessageFormat.format("{0}/specs/{1}/{2}/{3}", getContextPath(), getNoSpec().getFullIdentifier(),
+                memberType, actionId);
+        return new Element(xhtmlRenderer.aHref(uri, nakedObjectAction.getName(), "actionSpec", memberType,
+            HtmlClass.ACTION));
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionParamCount.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionParamCount.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionParamCount.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionParamCount.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,40 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectActionParamCount extends TableColumnNakedObjectAction {
+
+    public TableColumnNakedObjectActionParamCount(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("# Params", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final ObjectAction action) {
+        return xhtmlRenderer.p("" + action.getParameterCount(), HtmlClass.ACTION);
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionRealTarget.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionRealTarget.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionRealTarget.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionRealTarget.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,44 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectActionRealTarget extends TableColumnNakedObjectAction {
+
+    public TableColumnNakedObjectActionRealTarget(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Real Target", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final ObjectAction action) {
+        final String oidStrRealTarget = getOidStrRealTarget(action);
+        final String uri = MessageFormat.format("{0}/object/{1}", getContextPath(), oidStrRealTarget);
+        return new Element(xhtmlRenderer.aHref(uri, oidStrRealTarget, "actionRealTarget", "action", HtmlClass.ACTION));
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionReturnType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionReturnType.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionReturnType.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionReturnType.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,44 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectActionReturnType extends TableColumnNakedObjectAction {
+
+    public TableColumnNakedObjectActionReturnType(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Type", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final ObjectAction action) {
+        final String returnTypeFullName = action.getReturnType().getFullIdentifier();
+        final String uri = MessageFormat.format("{0}/specs/{1}", getContextPath(), returnTypeFullName);
+        return xhtmlRenderer.aHref(uri, returnTypeFullName, "actionReturnTypeSpec", "action", HtmlClass.ACTION);
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionType.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionType.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/actions/TableColumnNakedObjectActionType.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,39 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.actions;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnNakedObjectActionType extends TableColumnNakedObjectAction {
+
+    public TableColumnNakedObjectActionType(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Type", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final ObjectAction action) {
+        return xhtmlRenderer.p(action.getType().name(), HtmlClass.ACTION);
+    }
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAccess.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAccess.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAccess.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAccess.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,52 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.collections;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.resources.objects.TableColumnNakedObjectAssociation;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnOneToManyAssociationAccess extends
+    TableColumnNakedObjectAssociation<OneToManyAssociation> {
+
+    public TableColumnOneToManyAssociationAccess(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("Access", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    public Element doTd(final OneToManyAssociation collection) {
+        if (!collection.isVisible(getSession(), getNakedObject()).isAllowed()) {
+            return xhtmlRenderer.p(null, HtmlClass.PROPERTY);
+        }
+
+        final String contextPath = resourceContext.getHttpServletRequest().getContextPath();
+        final String collectionId = collection.getId();
+        final String uri =
+            MessageFormat.format("{0}/object/{1}/collection/{2}", contextPath, getOidStr(), collectionId);
+        return xhtmlRenderer.aHref(uri, collectionId, "collection", "nakedObject", HtmlClass.COLLECTION);
+    }
+
+}

Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAddTo.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAddTo.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAddTo.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/objects/collections/TableColumnOneToManyAssociationAddTo.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,69 @@
+/*
+ *  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.isis.viewer.restful.viewer.resources.objects.collections;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.resources.objects.TableColumnNakedObjectAssociationModifyAbstract;
+import org.apache.isis.viewer.restful.viewer.util.StringUtil;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnOneToManyAssociationAddTo extends
+    TableColumnNakedObjectAssociationModifyAbstract<OneToManyAssociation> {
+
+    public TableColumnOneToManyAssociationAddTo(final AuthenticationSession session, final ObjectAdapter nakedObject,
+        final ResourceContext resourceContext) {
+        super("AddTo", session, nakedObject, resourceContext);
+    }
+
+    @Override
+    protected String getFormNamePrefix() {
+        return "collection-";
+    }
+
+    @Override
+    protected String getHtmlClassAttribute() {
+        return HtmlClass.COLLECTION;
+    }
+
+    @Override
+    protected String getFormButtonLabel() {
+        return "Add";
+    }
+
+    /**
+     * Calls the <tt>addToCollection()</tt> Javascript function that lives in <tt>isis-rest-support.js</tt>
+     * 
+     * @param url
+     * @param associationId
+     * @param inputFieldName
+     *            - the name of the field in the form to read the value.
+     * @return
+     */
+    @Override
+    protected String invokeJavascript(final String url, final String associationId, final String inputFieldName) {
+        return MessageFormat.format("addToCollection({0}, {1}, {2}.value);", StringUtil.quote(url),
+            StringUtil.quote(associationId), inputFieldName);
+    }
+
+}



Mime
View raw message