Previous | Next | WireHose Developers Guide |
Since the main page and the tag driller page in Hello World
already allow users to browse through available resources, the "Or
click here to browse..." link is redundant on those pages.
WHSearchBox lets you control whether this link is shown via its
showBrowsePrompt
binding.
Ordinarily you'd set the showBrowsePrompt to false if you were to embed the search box directly into the main page and tag driller page. But in this case, the search box is embedded into the wrapper, and Hello World doesn't even have its own tag driller page component anyway.
Another technique might be to add a method to Wrapper.java which returns true or false depending on the current page. This method might look like this:
public boolean showBrowsePrompt() { return (context().page() instanceof MainPage || context().page() instanceof WHTagDrillerPage); }
or this:
public boolean showBrowsePrompt() { return ("WHMainPage".equals(helper().currentPage()) || "WHTagDrillerPage".equals(helper().currentPage()); }
However, this approach can be cumbersome to maintain. WireHose provides an alternative approach, which has the advantage of not requiring custom code: resolving the binding through the layout dictionary.
This entry in the layout dictionary sets WHSearchBox's showBrowsePrompt to true in all areas on all pages in all layouts by default:
defaults = { ... WHSearchBox = { showBrowsePrompt = YES; ...
You'll modify the layout dictionary so showBrowsePrompt resolves to false on the main page and the tag driller page.
WHMainPage = { pageName = MainPage; ...
Change it so it reads:
WHMainPage = { pageName = MainPage; WHSearchBox = { showBrowsePrompt = NO; }; ...
WHTagDrillerPage = { pageName = WHTagDrillerPage; ...
Change it so it reads:
WHTagDrillerPage = { pageName = WHTagDrillerPage; WHSearchBox = { showBrowsePrompt = NO; }; ...
How this works: WHSearchBox includes a WOConditional to determine whether to show the browse prompt. The conditional's condition is bound to showBrowsePrompt. WHSearchBox.java defines this method: public boolean showBrowsePrompt() { return booleanForBinding("showBrowsePrompt"); } If WHSearchBox's showBrowsePrompt binding
is bound directly to true or false, WHComponent's
You can use this technique in your own components. And if you're resolving simple string bindings, you don't even have to implement a method in your code -- WHComponent will resolve the value via the layout dictionary automatically. See the reference documentation for WHComponent for details. |
Copyright ©2000-2003 Gary Teter. All rights reserved. WireHose is a trademark of Gary Teter.