Authorize demo

Description
This page displays the authorize component in a tml template, with specific role content externalized inside blocks.
Notice the blockId parameter.


In Action
Choose your role : Admin
User
Anonymous



Your current role is :

Content displayed according to role :





TML Source code

		<!-- form -->
		<t:form>
			<fieldset>
				<legend>Choose your role :</legend>
				<t:radiogroup t:id="role" t:value="role">
		            <t:radio t:value="literal:ADMIN"/> Admin<br/>
		            <t:radio t:value="literal:USER"/> User<br/>
		            <t:radio t:value="literal:ANONYMOUS"/> Anonymous<br/>
		        </t:radiogroup>
		        <t:submit/>
	        </fieldset>
		</t:form>
		<br/><hr/><br/>
		
		Your current role is <b>${currentRole }</b> : <br/><br/>
		
		<fieldset>
			<legend>Content displayed according to role :</legend>
			<!-- Authorize display -->
			<ex:authorize any="ROLE_USER" block="userBlockAction"/>
			
			<ex:authorize any="ROLE_ADMIN" block="adminBlockAction"/>
			
			<t:block id="userBlockAction">
				If you see this block, you are on role User.<br/><br/>
			</t:block>
			
			<t:block id="adminBlockAction">
				If you see this block, you are on role Admin !
			</t:block>
		</fieldset>
		<br/><br/>
	



Java code

		public class Example2 extends BaseAuthorize
		{
		    @Inject
		    @Property
		    private Block userBlockAction;
		
		    @Inject
		    @Property
		    private Block adminBlockAction;
		
		}