Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

using querybuilder to find a component, is there any way to get the components model?

Avatar

Avatar
Validate 10
Level 4
TB3dock
Level 4

Likes

23 likes

Total Posts

172 posts

Correct Reply

4 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 4
TB3dock
Level 4

Likes

23 likes

Total Posts

172 posts

Correct Reply

4 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
TB3dock
Level 4

24-04-2021

If you find a component using querybuilder, it gives you a ValueMap of the properties. The components in question already have a full model defined. Is there any way to get the model back, instead of the value map?  

Hand writing method to copy each field into the value map would be onerous and fail as soon as the components model changed.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Level 2
Ritesh_M
Level 2

Likes

18 likes

Total Posts

21 posts

Correct Reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Boost 5
Level 2
Ritesh_M
Level 2

Likes

18 likes

Total Posts

21 posts

Correct Reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Ritesh_M
Level 2

25-04-2021

 

Hi @TB3dock ,

 

If I have understood your question correctly then you can always adapt a resource to your Model class like below-

 

for (Hit hit : searchResult.getHits()) {
Resource resource = hit.getResource();

MySlingModel myModel = resource.adaptTo(MySlingModel.class);

}

 

Let me know if it helps.

 

Thanks,

Ritesh

Answers (0)