Re: Access request from tml / standard servlet api role support

2018-04-27 Thread Kalle Korhonen
Tapestry-security (http://www.tynamo.org/tapestry-security+guide/) supports
request.isuserInRole and provides components similar to the one suggested,
i.e.


SAVE DATA


Kalle




On Fri, Apr 27, 2018 at 3:41 PM, pico.dev  wrote:

> Hi,
>
> Maybe you can implement a new conditional component that checks the role
> and render or not its body. Something like this:
>
> 
> SAVE DATA
> 
>
> See https://tapestry.apache.org/component-rendering.html
>
> Regards,
>
> El sáb., 28 abr. 2018 a las 0:12, Luca Arzeni ()
> escribió:
>
> > 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:
> >
> > 
> > SAVE DATA
> > 
> >
> > 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:
> >
> >
> > 
> > SAVE DATA
> > 
> >
> >
> > Is it possible to do this with tapestry5?
> >
> > Thanks in advance,
> > larzeni
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>


Re: Access request from tml / standard servlet api role support

2018-04-27 Thread pico.dev
Maybe other alternative is create a base page class that has this and
some/all application pages extends

@Inject
RequestGlobals m_requestGlobals;

public boolean isUserAdmin()

El sáb., 28 abr. 2018 a las 0:41, pico.dev () escribió:

> Hi,
>
> Maybe you can implement a new conditional component that checks the role
> and render or not its body. Something like this:
>
> 
> SAVE DATA
> 
>
> See https://tapestry.apache.org/component-rendering.html
>
> Regards,
>
> El sáb., 28 abr. 2018 a las 0:12, Luca Arzeni ()
> escribió:
>
>> 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:
>>
>> 
>> SAVE DATA
>> 
>>
>> 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:
>>
>>
>> 
>> SAVE DATA
>> 
>>
>>
>> Is it possible to do this with tapestry5?
>>
>> Thanks in advance,
>> larzeni
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>


Re: Access request from tml / standard servlet api role support

2018-04-27 Thread pico.dev
Hi,

Maybe you can implement a new conditional component that checks the role
and render or not its body. Something like this:


SAVE DATA


See https://tapestry.apache.org/component-rendering.html

Regards,

El sáb., 28 abr. 2018 a las 0:12, Luca Arzeni ()
escribió:

> 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:
>
> 
> SAVE DATA
> 
>
> 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:
>
>
> 
> SAVE DATA
> 
>
>
> Is it possible to do this with tapestry5?
>
> Thanks in advance,
> larzeni
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Access request from tml / standard servlet api role support

2018-04-27 Thread Luca Arzeni
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:


SAVE DATA


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:



SAVE DATA



Is it possible to do this with tapestry5?

Thanks in advance,
larzeni

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org