CVS: Tapestry/junit/src/net/sf/tapestry/junit/mock/c5 Visit.java,NONE,1.1.2.1 PageBlock.java,NONE,1.1.2.1
Howard Lewis Ship <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/mock/c5
In directory sc8-pr-cvs1:/tmp/cvs-serv29938/junit/src/net/sf/tapestry/junit/mock/c5
Added Files:
Tag: hship-2-3
Visit.java PageBlock.java
Log Message:
Revise statefulness checks in the action and direct services to be less intrusive.
--- NEW FILE: Visit.java ---
package net.sf.tapestry.junit.mock.c5;
import net.sf.tapestry.IRequestCycle;
import net.sf.tapestry.listener.ListenerMap;
/**
* For the Block tests, this simply stores a flag indicating whether
* the particular element (DirectLink, ActionLink or Form) has been
* triggered, as well as listener methods.
*
* @author Howard Lewis Ship
* @version $Id: Visit.java,v 1.1.2.1 2002/12/19 12:26:59 hship Exp $
* @since 2.4
*
**/
public class Visit
{
private boolean _directLinkTriggered;
private boolean _actionLinkTriggered;
private boolean _formTriggered;
private transient ListenerMap _listeners;
public boolean isActionLinkTriggered()
{
return _actionLinkTriggered;
}
public boolean isDirectLinkTriggered()
{
return _directLinkTriggered;
}
public boolean isFormTriggered()
{
return _formTriggered;
}
public void setActionLinkTriggered(boolean actionLinkTriggered)
{
_actionLinkTriggered = actionLinkTriggered;
}
public void setDirectLinkTriggered(boolean directLinkTriggered)
{
_directLinkTriggered = directLinkTriggered;
}
public void setFormTriggered(boolean formTriggered)
{
_formTriggered = formTriggered;
}
public void directTrigger(IRequestCycle cycle)
{
setDirectLinkTriggered(true);
}
public void actionTrigger(IRequestCycle cycle)
{
setActionLinkTriggered(true);
}
public void formTrigger(IRequestCycle cycle)
{
setFormTriggered(true);
}
public ListenerMap getListeners()
{
if (_listeners == null)
_listeners = new ListenerMap(this);
return _listeners;
}
}
--- NEW FILE: PageBlock.java ---
package net.sf.tapestry.junit.mock.c5;
import net.sf.tapestry.BaseComponent;
import net.sf.tapestry.IPage;
import net.sf.tapestry.IRequestCycle;
import net.sf.tapestry.components.Block;
/**
* An actual, reusable kind of component for the test suite. Works like
* a {@link net.sf.tapestry.components.RenderBlock}, but specified the
* {@link net.sf.tapestry.components.Block} to render in terms of
* a page name and a nested component id.
*
* @author Howard Lewis Ship
* @version $Id: PageBlock.java,v 1.1.2.1 2002/12/19 12:26:59 hship Exp $
* @since 2.4
*
**/
public class PageBlock extends BaseComponent
{
private String _targetPageName;
private String _targetBlockId = "block";
public String getTargetBlockId()
{
return _targetBlockId;
}
public String getTargetPageName()
{
return _targetPageName;
}
public void setTargetBlockId(String targetBlockId)
{
_targetBlockId = targetBlockId;
}
public void setTargetPageName(String targetPageName)
{
_targetPageName = targetPageName;
}
/**
* Used the targetPageName and targetBlockId (which defaults to "block")
* to obtain a reference to a Block instance, which is returned.
*
**/
public Block getTargetBlock()
{
IRequestCycle cycle = getPage().getRequestCycle();
IPage targetPage = cycle.getPage(_targetPageName);
return (Block)targetPage.getNestedComponent(_targetBlockId);
}
}
-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now! Before the Holidays pass you by.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/