I am trying to add a hidden property (key-value pair) to a page using a 'hidden' xtype in the page properties. But the property always returns a null/blank
The widget code is as below.
<keyvaluecheck jcr:primaryType="cq:Widget" defaultValue="myValue" hidden="{Boolean}true" name="./myKey" value="myValue" xtype="hidden"/>
The JSP code is as below: I should get "myValue" displayed but its blank. What may be wrong here ?
<%=currentPage.getProperties().get("myKey" , "") %>
Solved! Go to Solution.
Hello. I tried this with the following example:
defaultValue (String) = test
ignoreData (String) = true
jcr:primaryType (Name) = cq:Widget
name (String) = ./myKey
value (String) = test
xtype (String) = hidden
in a normal text component. In the text.jsp i extracted the value with the following code:
String myKey = (String)properties.get("./myKey");
and that worked. The thing is that it wont get saved into that property unless you first enter the edit mode for the component, so what I had to do was to first enter the edit mode of the component and then save. Then the hidden value turned up with the right value.
/Johan
Views
Replies
Total Likes
In addition to Johan's point about having to actually open the dialog and hit save, the other thing I'd point out is that you are accessing currentPage.getProperties - for that to work your widget has to be on your page properties dialog, not your component's dialog, and you have to have opened the page properties dialog and saved the dialog.
If you are setting defaults on either the page level, or fixed components within a template you can try using the approach of default template content - which is the jcr:content node of the template config and that nodes children. For example look at /apps/geometrixx-outdoors/templates/page_product as an example of a template that uses the approach - you can specify property values at the page level by adding them to the jcr:content node - much like sling:resourceType is specified, and you can add component defaults by specifying the appropriate child nodes.
Hello. I tried this with the following example:
defaultValue (String) = test
ignoreData (String) = true
jcr:primaryType (Name) = cq:Widget
name (String) = ./myKey
value (String) = test
xtype (String) = hidden
in a normal text component. In the text.jsp i extracted the value with the following code:
String myKey = (String)properties.get("./myKey");
and that worked. The thing is that it wont get saved into that property unless you first enter the edit mode for the component, so what I had to do was to first enter the edit mode of the component and then save. Then the hidden value turned up with the right value.
/Johan
Views
Replies
Total Likes
Views
Likes
Replies