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

sagarv13144480 24-01-2019

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.

Mark Solution

Are these answers useful?
Help other community members by marking useful answers as accepted.

Accepted Solutions (0)

Answers (3)

Answers (3)

antoniom5495929 24-01-2019

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

sagarv13144480 24-01-2019

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?

antoniom5495929 24-01-2019

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