Thanks Jesse! I'll upgrade as soon as 4.1.2 is released.

http://www.tapestryforums.com/

Jesse Kuhnert wrote:
Ah...I knew this sounded familiar.

I think it's fixed in 4.1.2-snapshot

https://issues.apache.org/jira/browse/TAPESTRY-1204

On 4/22/07, Paul Stanton <[EMAIL PROTECTED]> wrote:

If I change the accessor method boolean isMetaSecure to String
getMetaSecure it works fine.

So the problem can be defined as: @InjectMeta only works with String
types. This is obvious after reading the documentation, but the Vlib
example (written by howard?) is misleading as it suggests usage with
booleans works.

Paul Stanton wrote:
> I saw a neat solution to meta data using annotations in the Vlib
> example that comes bundled with Tapestry 4.1.1.
> *Code:*
> @Meta({"anonymous-access=false", "admin-page=false"})
> public abstract class VlibPage extends BasePage implements
> IErrorProperty,
>        IMessageProperty, PageValidateListener, OperationsUser
> {
> ...
>    @InjectMeta("anonymous-access")
>    public abstract boolean getAllowAnonymousAccess();
>
>    @InjectMeta("admin-page")
>    public abstract boolean isAdminPage();
> ...
>    public void pageValidate(PageEvent event)
>    {
>        if (isAdminPage()) ensureUserIsLoggedInAsAdmin();
>
>        if (!getAllowAnonymousAccess()) ensureUserIsLoggedIn();
>    }
> ...
> }
>
> Subclasses of VlibPage can over-ride the value for "anonymous-access"
> or "admin-page" using the same @Meta annotation:
> *Code:*
> @Meta( { "page-type=Search", "anonymous-access=true" })
> public abstract class Home extends VlibPage
> ...
>
>
>
> I thought I'd give it a go:
>
> base class for pages, defaults meta value to true
> *Code:*
> @Meta({"meta-secure=true"})
> public abstract class BasePage extends
> org.apache.tapestry.html.BasePage implements PageValidateListener
> {
>   @InjectMeta("meta-secure")
>   public abstract boolean isMetaSecure();
> ...
>   public boolean isSecure()
>   {
>      return true;
>   }
> ...
>   public void pageValidate(PageEvent event)
>   {
>      System.out.println(this.getClass().getName() + " - method:" +
> isSecure() + " - meta:" + isMetaSecure());
>   }
> ...
> }
>
>
>
> home page over-rides meta value to false
> *Code:*
> @Meta({"meta-secure=false"})
> public abstract class Home extends BasePage
> {
>   @Override
>   public boolean isSecure()
>   {
>      return false;
>   }
> }
>
>
>
> list clients page over-rides value to true (for testing purposes)
> *Code:*
> @Meta({"meta-secure=true"})
> public abstract class ListClients extends BasePage
> ...
>
>
>
> list projects page does not over-ride super value
> *Code:*
> public abstract class ListProjects extends BasePage
>
>
>
> unfortunately, it doesn't seem to work. The value always reads false.
> *Code:*
> $Home_84 - method:false - meta:false
> $ListProjects_95 - method:true - meta:false
> $ListClients_137 - method:true - meta:false
>
>
>
> I've stepped through some stacks and have found that the value is
> being correctly set to the String "true" and "false" in the components
> properties, but somewhere between
> ComponentPropertySourceImpl.getComponentProperty and my property
> injected method isMetaSecure, "true" is not being converted to boolean
> true.
>
> Has anyone come across this problem?
>
> Has anyone successfully used booleans in meta data via the page
> specification as opposed to class annotations?
>

--
Paul Stanton
Gunn Software
PH: (02) 9918 3666 (ext 503)




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Paul Stanton
Gunn Software
PH: (02) 9918 3666 (ext 503)




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to