Adding a hint to indicate links are external
Written on November 27, 2008 – 12:17 am | by mpayne
Good tip from — >
http://www.learningjquery.com/2008/08/quick-tip-dynamically-add-an-icon-for-external-links#more-103
Struts2 needs better Sitemesh Support
Written on November 11, 2008 – 12:26 pm | by mpayne
If one looks at the sitemesh 2.3 example application, an application can have both Freemarker and JSP decorators.
In addition, one has very flexible usage of sitemesh tag libs from with a decorator.
For instance one can reference freemarker’s taglib within freemarker via.
<#assign page=JspTaglibs["/WEB-INF/sitemesh-page.tld"]>
This allows one to include decorated external content from within a freemarker decorator.
e.g. <@page.applyDecorator page=”/google.html” name=”panel” />
—> more complete example that works in Sitemesh “Vanilla”.
<#assign page=JspTaglibs["/WEB-INF/sitemesh-page.tld"]>
<html>
<head>
<title>Freemarker Decorator - ${title}</title>
<link href=”${base}/decorators/main.css” rel=”stylesheet” type=”text/css”>
${head}
</head>
<body>
<div id=”pageTitle”>${title}</div>
<hr/>
${body}
<@page.applyDecorator page=”/google.html” name=”panel” />
<div id=”footer”>
<b>Disclaimer:</b> This site is an example site to demonstrate SiteMesh. It serves no other purpose.
</div>
</body>
</html>
There does not have look like there has been much movement one these issues. Once fixed I am hoping we can
Common maven Archetypes to keep a reference to
Written on September 27, 2008 – 2:20 pm | by mpayne
Need to keep this site handy.
Eclipse P2= Epic Fail
Written on August 11, 2008 – 9:51 am | by mpayne
On both my windows work machine and Linux Desktop at home the p2 update manager was not able to cut it. Halfway though re-installing various I used to, I used to linked in via external folder(using the .link method), P2 got into an unresolvable dependency problem that pretty much locked it from doing any further updates. This happened twice(e.g. both machines).
By looking p2 removal note, I used the script provided in this bug issue.
You pretty much put downloaded eclipse archive(s) in the “source” folder and let the script do its thing.
With the p2 deleted from my eclipse installations, updates seem to go smooth again.
Given the popularity of the bug, I am going to guess that I am not the only one who is having a problem.
Dealing with unmapped fields in XStream
Written on July 30, 2008 – 11:10 am | by mpayne
There is a jira patch proposed here for handling XML. However that patch still needs to mature(see limitations) and gain acceptances.
What might not be obvious(a.k.a poorly documented), is that stock XStream already has the
capability to handling this for many use cases.
The test class com.thoughtworks.acceptance.CustomMapperTest
Contains a method that demonstrates such an example.
public void testCanBeUsedToOmitUnexpectedElements() {
String expectedXml = “” +
“<software>\n” +
“ <version>1.0</version>\n” +
“ <vendor>Joe</vendor>\n” +
“ <name>XStream</name>\n” +
“</software>”;
xstream = new XStream() {
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
public boolean shouldSerializeMember(Class definedIn, String fieldName) {
return definedIn != Object.class ? super.shouldSerializeMember(definedIn, fieldName) : false;
}
};
}
};
xstream.alias(”software”, Software.class);
Software out = (Software) xstream.fromXML(expectedXml);
assertEquals(”Joe”, out.vendor);
assertEquals(”XStream”, out.name);
}
In the example above the Software class consists of properties.
public String vendor;
public String name;
Without the “MapperWrapper” the xml node “<version>1.0</version>” would generate an exception.
Several years later and NetBeans still doesn’t do it for me
Written on May 27, 2008 – 10:48 pm | by mpayne
I was hoping it would. I would like to use it to play around with some ruby development. I still may. However, for Java development it seems like its missing some fairly basic functionality that I have become use to in eclipse.
One of the basic things I was trying to do is setup more than one run profile for a project. In this particular project there are several main class that take command line arguments. In eclipse setting such profiles is fairly trivial. However, netbeans seems like it only wants one per project or right click on a file “Run” with no arguments.
What makes jQuery a Good choice?
Written on May 1, 2008 – 4:21 pm | by mpayne
Found this blog post on What Makes jQuery a Good Choice?
Thought this provided a pretty good summary.
There is a response here. I don’t have a problem with prototype, though I have latched on to jQuery(probably aided by its better documentation).
My bad experiences root from Dojo, its bloat and the way its was bundled with Struts2
Changing plugs on my 2001 Xterra
Written on April 21, 2008 – 11:03 am | by mpayne
@78800 miles I changes 5 of the six plugs. With daylight quickly disappearing, I decided to punt on doing the six plug till I found out some more information about it.
I found this guide, for changing plugs. I will have to take another crack at it when the weather is nice.
There is also this guide for changing the diff fuild.
Struts2 needs a new AliasInterceptor
Written on April 16, 2008 – 11:00 am | by mpayne
The original aliasInteceptor works fine for gluing together actions with different parameter names that need to be clued together. The limitation with the existing solution is that properties for both name an alias need to exist in the stack.
The world keeps evolving though. Developers make frequent use of richer javascript widgets such as jQuery’s flexgrid or jqGrid. These widgets can consume a specific JSON response and dish out their own unique set of named parameters to the server side. This presents a challenge when trying to leverage existing back end code that works great, it just doesn’t match up name wise to the parameters names coming in for a specific view.
Assume one has a some abstract PagingQueryAction(children just set query/queryCount implementations) that can accept incoming parameters of:
int pageSize = 10; // results per page, default 10
int currentPage;
String filter;
String sortorder = “asc”;
String sortname = “”;
This works fine and dandy for some existing web views, but if one wanted to make use of FlexGrid, they would create setters named.
page 3 qtype name query rp 15 sortname iso sortorder asc
jqGrid has yet another set of name parameters that its submits.
Making new implementations of things because some UI widgets is hardcoded to respond with a specfic set can be a PITA.
If there existed an AliasInterceptor that would allow one to adapt to these widget requirements people would have another solution at their disposal.
example of a mapping:
<!– usaged
<param name=”aliases”>#{ ‘incomingName’ : ‘actionPropertyName’}</param>
–>
<package name=”json” extends=”inventoryDefault” namespace=”/json”>
<action name=”summaryPagedJSON” class=”stateSummary”>
<param name=”pageSize”>15</param> <!– change default here –>
<param name=”aliases”>#{ ‘query’ : ‘filter’, ‘rp’:'pageSize’,'page’:'currentPage’ }</param>
<result name=”success” type=”freemarker”>
json-pageSummary.ftl
</result>
<result name=”input” type=”freemarker”>
json-pageSummary.ftl
</result>
</action>
If one wanted to adapt the paging action for jqGrid, they’d simply need to
supply an alias parameter of:
<param name=”aliases”>#{ ’searchString’ : ‘filter’,'page’:'currentPage’, ’sord’:’sortorder’, ’sidx’:’sortname’ }</param>
(Note the freemarker template producing the JSON response may need to differ slighty as well)
This proposed alias interceptor looks for the alias within “invocationParameters” instead of the stack.
Perhaps we need to rename things. The old AliasInterceptor is name ChainingAliasInterceptor
and the new one is ParameterAliasInterceptor.
Or perhaps the alias functionality should just be built in to the existing ParameterInterceptor.
snippet below
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionConfig config = invocation.getProxy().getConfig();
ActionContext ac = invocation.getInvocationContext();
// get the action’s parameters
final Map configParameters = config.getParams();
final Map invocationParameters = ac.getParameters();
if (configParameters.containsKey(aliasesKey)) {
String aliasExpression = (String) configParameters.get(aliasesKey);
OgnlValueStack stack = (OgnlValueStack) ac.getValueStack();
Object obj = stack.findValue(aliasExpression);
if (obj != null && obj instanceof Map) {
// override
Map aliases = (Map) obj;
Iterator itr = aliases.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry entry = (Map.Entry) itr.next();
String alias = entry.getKey().toString();
String setterName = (String) entry.getValue();
Object value = invocationParameters.get(alias);
if (null != value) {
stack.setValue(setterName, value);
}
}
} else {
log.debug(”invalid alias expression:” + aliasesKey);
}
}
return invocation.invoke();
}