Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:48:15+00:00 2026-06-15T22:48:15+00:00

I’m rolling my own IAuthorizationStrategy for Wicket 1.5.x I’ve setup type annotation for pages

  • 0

I’m rolling my own IAuthorizationStrategy for Wicket 1.5.x I’ve setup type annotation for pages to use with isInstantiationAuthorized(). It works well and I’d like to use annotations for isActionAuthorized() as well. Ideally I’d like to be able annotate local variables and then check the annotations in my AuthStrategy. From what I’ve read Local variable Annotation doesn’t work that way.

Is there any kind of known work around, maybe some sort of Compile time annotation processing to turn an annotated local variable into an “anonymous” subclass with the annotation as a type annotation?

For the record, the annotation I’m trying to use looks like this:

@Retention(RetentionPolicy.Runtime)
@Target(ElementType.Type, ElementType.LOCAL_VARIABLE)
public @interface AdminOnly
{
  int isVisible() default 0;
  int isEnabled() default 1;
}

UPDATE

So based on @Xavi López’es answer what I was hoping to do isn’t exactly possible.
Annotated LocalVariables should be available at compile time though. Is there some way maybe I could use them as a shortcut for boiler-plating the meta-data code examples that are available in Wicket Examples or the excellent Apache Wicket Cookbook?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:48:16+00:00Added an answer on June 15, 2026 at 10:48 pm

    I’ve struggled with a similar issue some time ago with Wicket 1.3.x, and didn’t find any way to achieve this with annotations. Annotations on local variables can’t be retained at run-time, as explained in the JLS (9.6.3.2. @Retention):

    An annotation on a local variable declaration is never retained in the binary representation.

    In this related question: How can I create an annotation processor that processes a Local Variable? they talked about LAPT-javac, a patched javac version to allow this. On their site there’s a link to the Type Annotations Specification (JSR 308), which will hopefully address this subject (JDK 8 ?).

    I ended up defining a plain old interface with a related functionality code:

    public interface RestrictedComponent {
        Integer getFunction();
    }
    

    The main problem with this approach is that it’s not possible to make instant anonymous subclasses of a specific class implement other interfaces (such as Component c = new TextField() implements AdminOnly { }) , but you can always define Component extensions that just implement RestrictedComponent in a class:

    public abstract class RestrictedTextField extends TextField implements RestrictedComponent { } 
    

    Finally, I ended up implementing a RestrictedContainer that just subclassed WebMarkupContainer and put every secured component inside one, modelling it with a <wicket:container> in the markup.

    public class RestrictedContainer extends WebMarkupContainer implements RestrictedComponent {
        private final Integer function;
        public RestrictedContainer(String id, IModel model, final Integer function) {
            super(id, model);
            this.function = function;
        }
        public RestrictedContainer(String id, final Integer funcionalitat) {
            super(id);
            this.function = function;
        }
        public Integer getFunction() {
            return function;
        }
    }
    

    And then in the Authorization Strategy checked for component instanceof RestrictedComponent and returned true or false depending on user permissions on the associated function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.