Highlighted

what is the best approach? Servlet or Node

Avatar

Avatar

keerthid7215849

Avatar

keerthid7215849

keerthid7215849

21-02-2018

As of now, we have a list of people as a node for each person in jcr. We are trying to get all the people names in a drop-down using a servlet.

But, we can also create a node with a property holding the all the names as a json and call the property value in node instead of calling a servlet every time when we use it.

Also, I need to update the JSON value in this node whenever a new name added or existing name deleted.

I'm not sure about which approach I need to implement. servlet or creating a node that hold names.

Please suggest with pros and cons.

,

Replies

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

21-02-2018

Where are you trying to display the list - in an AEM component displayed in a web page? Or a component dialog Select field? Please provide more details.

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

21-02-2018

If you are trying to display the list in a Granite Select Field - then you can populate it with child nodes.

Highlighted

Avatar

Avatar

cquser1

Avatar

cquser1

cquser1

22-02-2018

Hi,

Just a thought.

In one of our implementations we had used the servlet approach.

Based on what you mentioned "But, we can also create a node with a property holding the all the names as a json....Also, I need to update the JSON value in this node whenever a new name added or existing name deleted".

So, to get all the names of users in json format in a node:

1] You are planning to write a listener that will be watching for any addition/deletion to the users area and update the json information in a node?

Probably this can also be done without much of a performance issue. Just that the logic needs to be in place to handle the incremental additions/deletions to the user list and any modifications.

Highlighted

Avatar

Avatar

keerthid7215849

Avatar

keerthid7215849

keerthid7215849

22-02-2018

We are trying to display in component dialog select field

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

22-02-2018

Follow this:

Select fields.png

Here is an example procudure to add a Select field to an existing Touch UI Dialog and populate it with nodes - as shown above:

Perform these tasks:

1 Select the node at:

/apps/Lab2018/components/content/firstcomponent/cq:dialog/content/items/herotext/items/column/items.

  1. Right click and select Create, Create Node. Enter the following values:

•    Name: type

•    Type: nt:unstructured

  1. Click on the following node: /apps/Lab2018/components/content/firstcomponent/cq:dialog/content/items/herotext/items/column/items/ type.
  2. Add the following properties to the type node:

•    fieldDescription (String) - Select Size

  • fieldLabel (String) - Size

•    name (String) - ./size (you reference this value to read this value of this component field)

•    sling:resourceType (String) - granite/ui/components/coral/foundation/form/select

  1. Select the node at:

/apps/Lab2018/components/content/firstcomponent/cq:dialog/content/items/herotext/items/column/items/type.

  1. Right click and select Create, Create Node. Enter the following values:

•    Name: items

•    Type: nt:unstructured

  1. Select the node at:

/apps/Lab2018/components/content/firstcomponent/cq:dialog/content/items/herotext/items/column/items/type/items.

  1. Right click and select Create, Create Node. Enter the following values:

•    Name: small

•    Type: nt:unstructured

  1. Add the following properties to the small node:

•    text (String) - small

•    value (String) – small

  1. Click on the following node: /apps/Lab2018/components/content/firstcomponent/cq:dialog/content/items/herotext/items/column/items/ type.
  2. Right click and select Create, Create Node. Enter the following values:

•    Name: medium

•    Type: nt:unstructured

12 Add the following properties to the medium node:

•    text (String) - medium

•    value (String) – medium

  1. Click on the following node: /apps/Lab2018/components/content/firstcomponent/cq:dialog/content/items/herotext/items/column/items/ type.
  2. Right click and select Create, Create Node. Enter the following values:

•    Name: large

•    Type: nt:unstructured

15 Add the following properties to the large node:

•    text (String) - large

•    value (String) - large

Highlighted

Avatar

Avatar

pratekumar

Avatar

pratekumar

pratekumar

22-02-2018

If you are trying to display the list in a component dialog then you need to write a servlet/datasource. It will automatically change values if you delete something from the nodes.