Wasim Wani
Wasim Wani

Reputation: 555

Getting value of checkbox from dialog

I am fairly new to Day Cq5.I am having a checkbox in my dialog and i want to retrieve its boolean value in my jsp when user selects or deselects it .Kindly help

Upvotes: 5

Views: 11640

Answers (3)

Andre Haverdings
Andre Haverdings

Reputation: 917

This works for me

Properties for dialog field:

name: ./checkbox1
type: checkbox
xtype: selection

code:

boolean isChecked1 = properties.get("checkbox1", false);

Upvotes: 5

Fernando
Fernando

Reputation: 485

If you want to retrieve the value from your component's JSP, then do this:

boolean foobar = properties.get("nameOfYourCheckbox", true);

You can specify the default value by using true/false as the second argument.

Hope that helps.

Upvotes: 5

Bojana Popovska
Bojana Popovska

Reputation: 601

Every widget you add to your components dialog is stored in CRX as a property to the cq:Component node. All this properties can be accessed in the jsp by typing properties. in EL brackets (like this: ${properties.<name_of_property>}). Don't forget to include the /libs/foundation/global.jsp file to your jsp.

Upvotes: 0

Related Questions