I've been experimenting with Jelly Swing recently after finding Groovy Swing problematic, trying to see whether it will make GUI prototyping faster. I may have missed it, but I couldn't find a tag in any of the tag libraries to access a static class field. There's invokeStatic for invoking static methods. For the project I'm working on, I wrote a GetStaticTag that works like this:
<v:getStatic var="closeOperation" className="javax.swing.JFrame" field="EXIT_ON_CLOSE"/> That allowed me to then do: <frame title="Tree Frame" var="frame" size="400,400" defaultCloseOperation="${closeOperation}"> ... </frame> I think it's pretty important to be able to access static fields and that a getStatic (or some other name) tag would be useful to have in the core tag library. If I convert my GetStaticTag class code to the style convention used in the Jelly source and add a Jelly test for it, is it all right for me to add it to the source tree? I've appended the simple class at the end of this message. I guess the question is a two-parter: 1. Does the Jelly core tag library need a getStatic tag to complement getStatic? [ ] +1 Yes, it's generally useful. [ ] -1 No, it's easy for someone who needs it to make their own tag. 2. May I commit code for the tag to the repository assuming I convert it to the proper style and provide a Jelly test? [ ] +1 Go right ahead, we can tweak the code after it's committed. [ ] -1 No, we need to agree on what to call the tag, you should try more than one class loader in doTag, some other reason ... daniel package org.savarese.vserv.jelly; import org.apache.commons.jelly.*; public class GetStaticTag extends TagSupport { private String __var; private String __field; private String __className; public void setVar(String var) { __var = var; } public void setField(String field) { __field = field; } public void setClassName(String className) { __className = className; } public void doTag(XMLOutput output) throws JellyTagException { String message = null; if(__var == null) message = "var"; else if(__field == null) message = "field"; else if(__className == null) message = "className"; if(message != null) throw new MissingAttributeException(message); try { Class type = getClass().getClassLoader().loadClass(__className); Object result = type.getField(__field).get(null); JellyContext context = getContext(); context.setVariable(__var, result); } catch(Throwable t) { throw new JellyTagException("Could not access " + __className + "." + __var + ". Original exception message: " + t.getMessage(), t); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]