Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Page Property shouldn't be allowed to author but should change value dynamically

Avatar

Level 3

We are having a requirement where in the page property should be disabled to author/edit

but can be seen in touch ui.

while it's value should change via code in the node.

3 Replies

Avatar

Level 7

Hi,

could you try to put in your cq:dialog, inside the field that you need to make "readyOnly" the property disabled=true.

Screen Shot 2019-01-24 at 12.34.09.png

In this way the property is not editable from the page properties, but it's visible.

Screen Shot 2019-01-24 at 12.38.55.png

Let me know if this could be helpfull.

Thanks,
Antonio

Avatar

Level 3

Hi Antonio,

disabled=true is not allowing to change the field via code.

It gets persisted in the property but after hitting save and close.

It is still reflecting the old value.

Any readOnly available for page property?

Avatar

Level 7

Hi, could you share the code that you are using in order to change the property value?

I tested it, by using the disabled property and the following snippet to change a property by using java api:

ResourceResolver resourceResolver = getResourceResolver(resourceResolverFactory);

Resource resource = resourceResolver.getResource("/content/we-retail/language-masters/en/jcr:content");

Node node = resource.adaptTo(Node.class);

node.setProperty("jcr:title", "PIPPO");

node.getSession().save();

And it works properly. I'm able to change the value by using java code and the new value is visible in the page property dialog that is not editable by the authors.

Let me know.

Thanks,

Antonio