Hi All


I am thinking on do some refactor on AjaxDirectLink , AjaxSubmit, AjaxEventSubmit...
and the so many similar components that all have effects, statusElement, popup ...,
because I am going to add a new component that may have these parameter, (AjaxAutoRefresh)

that would be introduce a new interface something like AjaxInvoke or AjaxParameter, and make those components to implement.

public interface AjaxParameter {

    public abstract Collection getUpdateComponents();

    public abstract Collection getUpdateBlocks();

    public abstract String getUpdateObject();

    public abstract boolean isDirect();

    public abstract String getEffects();

    public abstract String getStatusElement();

    public abstract String getPreEffects();

    public abstract String getPopup();
}

and add some util method to cut out the duplicated code like:

            if (getUpdateObject() != null)
                parmMap.put("updateObject", getUpdateObject());
            else
                parmMap.put("updateObject", "null");
            if (getEffects() != null) {
                parmMap.put("effects", ScriptUtils
                        .escapeJavaScriptHash(getEffects()));
            } else {
                parmMap.put("effects", "{}");
            }
            if (getPreEffects() != null) {
                parmMap.put("preEffects", EffectStringUtils.createPreEffectsScript(
                        getPreEffects(), getUpdateComponents()));
            }
            if (getPopup() != null) {
                parmMap.put("popup", ScriptUtils.escapeJavaScriptHash(getPopup()));
            }
            if (getBackLink() != null)

that may be :
     someUtils.generateAjaxParameter(this)


I am not sure whether this method works.  so I want to write some tests on those components, and to protect my refactorings.
but writing test on tapestry component sames difficult. So does anyone knows how to test tapestry component,
 I think it is not as simple as TestAny etc in tapestry source directory when testing AjaxDirectLink.

Should we apply the TDD practice on developing tacos?





Reply via email to