Access request from tml / standard servlet api role support

"Luca Arzeni" <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <trinity-27ad9b88-97ac-4248-9c7e-c213552172ef-1524867145435@3c-app-mailcom-lxa03>
Hi,
I'm using tapestry5.4 with java 8.

I am using the standard servlet API to check if a user is in role or not, to hide or show buttons, links, and so on.

For example, I need to show a button to the user only if the user has been granted a role.

My usual way to to this is:

1) create a method in the page, for example:

@Inject
RequestGlobals m_requestGlobals;

public boolean isUserAdmin() {
	if (m_requestGlobals == null) {
		return false;
	}
	return m_requestGlobals.isUserInRole("ADMIN");
}

2) then, in the tml, check the method using a t:if component, for example:

<t:if test="userAdmin">
		<a t:id="saveButton" type="button" href="#">SAVE DATA</a>
</t:if>

This is not so good, since I must reimplement the same method in many pages.

Is there any way could I access the requestGlobals directly from tml?

My goql would be to write, directly in the tml, something like:


<t:if test="request.isuserInRole('ADMIN')">
	<a t:id="saveButton" type="button" href="#">SAVE DATA</a>
</t:if>


Is it possible to do this with tapestry5?

Thanks in advance,
larzeni

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.