You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Meredith <ps...@t-online.de> on 2003/07/11 15:43:45 UTC

Alternative to catching ApplicationRuntimeException

Hi,

My Border component renders a block "RightColumnBlock" in the containing
page. Some of my pages don't have this block, so I came up with:


public Block getRightColumnBlock() {
	Block block = null;

	try {
		block = (Block) getPage().getNestedComponent("leftNavigation");
	} catch (ApplicationRuntimeException are) {
		return new Block();
	}
	
	return block;
}

plus:

<span jwcid="@RenderBlock" block="ognl:leftColumn"/>

in my Border component - which works.

My question is: As the API states that ApplicationRuntimeException is
not meant to be caught, is there another method of checking whether the
containing page has the block or not? Am I going about this the wrong
way?

 - John

-- 
John Meredith <ps...@t-online.de>


Re: Alternative to catching ApplicationRuntimeException

Posted by Bryan Lewis <br...@maine.rr.com>.
How about using this if-statement instead of the try-catch?

    if (getPage().getComponents().containsKey("leftNavigation")) {

I haven't actually tried it, but is looks reasonable in the API docs.