tapestry5tapestry5
Conditionally renders its body. May render its tag and any informal parameters.
Component Parameters
NameDescriptionTypeFlagsDefaultDefault PrefixSince

else
An alternate org.apache.tapestry5.Block to render if org.apache.tapestry5.corelib.base.AbstractConditional#test() is false. The default, null, means render nothing in that situation.
negate

test
If true, then the body of the If component is rendered. If false, the body is omitted.
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<body>
<h1>Welcome!</h1>
<t:if test="user">
Welcome back, ${user.firstName}
<p:else>
<t:pagelink name="login">Login</t:pagelink> /
<t:pagelink name="register">Register</t:pagelink>
</p:else>
</t:if>
. . .
</html>
Here, the main text is rendered if the user is logged in (the user property willbe non-null after the user logs in). Otherwise, links to a login and registerpage are rendered.
Note the use of thep:namespace (new in Tapestry 5.1). In 5.0, this would be.
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-28358-1.html
也解决了男人太多的问题