Update of /var/cvs/contributions/didactor2/src/core/java/nl/didactor/taglib
In directory james.mmbase.org:/tmp/cvs-serv28988/java/nl/didactor/taglib
Modified Files:
MayTag.java
Added Files:
DidactorHelper.java
Log Message:
using 1.9's Actions in
See also:
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/core/java/nl/didactor/taglib
DidactorHelper.java is new
Index: MayTag.java
===================================================================
RCS file:
/var/cvs/contributions/didactor2/src/core/java/nl/didactor/taglib/MayTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- MayTag.java 28 Sep 2005 10:49:24 -0000 1.3
+++ MayTag.java 21 Jan 2008 17:31:53 -0000 1.4
@@ -7,8 +7,13 @@
import javax.servlet.jsp.*;
import javax.servlet.Servlet;
import org.mmbase.bridge.jsp.taglib.*;
+import org.mmbase.bridge.jsp.taglib.util.Attribute;
+import org.mmbase.bridge.jsp.taglib.util.Referids;
+import org.mmbase.security.Action;
import org.mmbase.util.logging.Logger;
import org.mmbase.util.logging.Logging;
+import org.mmbase.util.functions.Parameters;
+
import nl.didactor.component.Component;
import java.util.StringTokenizer;
@@ -17,39 +22,33 @@
* @author Johannes Verelst <[EMAIL PROTECTED]>
*/
public class MayTag extends CloudReferrerTag {
- private static Logger log =
Logging.getLoggerInstance(MayTag.class.getName());
- private String component;
- private String action;
- private String[] arguments = new String[0];
+ private static final Logger log = Logging.getLoggerInstance(MayTag.class);
+ private Attribute component = Attribute.NULL;
+ private Attribute action = Attribute.NULL;
+ private Attribute referids = Attribute.NULL;
/**
* Set the value for the 'component' argument of the May tag
* @param component Component value
*/
- public void setComponent(String component) {
- this.component = component;
+ public void setComponent(String component) throws JspException {
+ this.component = getAttribute(component);
}
/**
* Set the value for the 'action' argument of the May tag
* @param action Action identifier
*/
- public void setAction(String action) {
- this.action = action;
+ public void setAction(String action) throws JspTagException {
+ this.action = getAttribute(action);
}
/**
* Set the value for the 'arguments' argument of the May tag, Comma
seperated.
* @param arguments Optional arguments
*/
- public void setArguments(String arguments) {
- StringTokenizer st = new StringTokenizer(arguments, ",");
- if (st.countTokens() > 0) {
- this.arguments = new String[st.countTokens()];
- for (int i=0; i<st.countTokens(); i++) {
- this.arguments[i] = st.nextToken();
- }
- }
+ public void setReferids(String arguments) throws JspTagException {
+ this.referids = getAttribute(arguments);
}
/**
@@ -63,16 +62,27 @@
* </ul>
*/
public int doStartTag() throws JspTagException {
- Component comp = Component.getComponent(component);
+ Component comp = Component.getComponent(component.getString(this));
if (comp == null) {
log.error("Component "+ component + "cannot be found" );
return SKIP_BODY;
}
- boolean[] value = new boolean[0];
+ boolean[] value;
+ Action a = comp.getActions().get(action.getString(this));
+ if (a == null) {
+ throw new JspTagException("No such action " + action + " defined
for component " + comp + ". The possible actions are " + comp.getActions());
+ }
+ Parameters params = a.createParameters();
+ fillStandardParameters(params);
+ DidactorHelper.fillStandardParameters(this, params);
+ for (Map.Entry entry : ((Collection<Map.Entry>)
Referids.getReferids(referids, this).entrySet())) {
+ String key = (String) entry.getKey();
+ params.set(key, entry.getValue());
+ }
try {
- value = comp.may(action, getCloudVar(),
getContextProvider().getContextContainer(), arguments);
+ value = comp.may(getCloudVar(), a, params);
} catch (IllegalArgumentException e) {
throw new JspTagException(e.getMessage());
}
@@ -82,11 +92,11 @@
} else {
try {
pageContext.getOut().print( "<h1>Permission denied!</h1>");
- }
- catch (java.io.IOException e) {
- log.error( "di:may IO error:" + e.getMessage());
- }
return SKIP_BODY;
+ } catch (java.io.IOException e) {
+ throw new TaglibException(e.getMessage(), e);
+ }
+
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs