I have a component and I would like to use a dropdown menu. However, I want to hide certain options for the Author user group.
Admin should see:
But an author should only see:
How can I incorporate the access controls at the script level for a specific tab inside a component?
Solved! Go to Solution.
Views
Replies
Total Likes
Take a look at /libs/cq/personalization/components/traits/percentile for an example of a dynamically generated selection list. The dialog sets the options property of the select widget to be $PATH.options.json. There is a JSP that is responsible for generating the select options - /libs/cq/personalization/components/traits/percentile/options.json.jsp. So in your case your JSP would check the user's group membership and return the correct JSON based on the group membership. You could also use a OSGI Sling servlet instead of a JSP if desired.
Views
Replies
Total Likes
It deponds where you are retrieving the drop down options. If the options are generating Or hard coded Or coming from external system. Then the servlet rendering the dropdown list in cq should implement the logic based on the user member to output right option.
Views
Replies
Total Likes
The list options would be hardcoded. When the user makes their selection and presses OK in the component to Save, the associated action would take place. Example - Author user selects Yellow from the list (could also use radio buttons). When Author clicks Yes, the background of the header turns yellow.
Views
Replies
Total Likes
Take a look at /libs/cq/personalization/components/traits/percentile for an example of a dynamically generated selection list. The dialog sets the options property of the select widget to be $PATH.options.json. There is a JSP that is responsible for generating the select options - /libs/cq/personalization/components/traits/percentile/options.json.jsp. So in your case your JSP would check the user's group membership and return the correct JSON based on the group membership. You could also use a OSGI Sling servlet instead of a JSP if desired.
Views
Replies
Total Likes
I don't seem to have the percentile folder under traits. Can you paste the code or is there another example?
Views
Replies
Total Likes
which version of aem you are using?
Views
Replies
Total Likes
My apologies, I'm using CQ5. (CRXDE Lite 2.3.15).
Views
Replies
Total Likes
I think the question was 5.5 or 5.6.
At the core what you need is code that will generate a JSON response in this format:
[
{"value":"0-10","text":"0% - 10%"},
{"value":"10-20","text":"10% - 20%"},
{"value":"20-30","text":"20% - 30%"},
{"value":"30-40","text":"30% - 40%"},
{"value":"40-50","text":"40% - 50%"},
{"value":"50-60","text":"50% - 60%"},
{"value":"60-70","text":"60% - 70%"},
{"value":"70-80","text":"70% - 80%"},
{"value":"80-90","text":"80% - 90%"},
{"value":"90-100","text":"90% - 100%"}
]
You can do that with either a JSP or a Servlet. Doing a selector based JSP (like putting a JSP named options.json.jsp under your component is the simplest way to accomplish this.
Then you set your options property on your select widget to be $PATH.options.json.
Views
Replies
Total Likes
( I'm using Version 5.5 )
Ok. I'm just a beginner so some of this seems foreign but I think I have enough to play around with.
Any additional comments/alternative solutions are welcome!
I'll leave this item "open" for a few days while I try to work through it.
Views
Replies
Total Likes