What is the difference between serviceParameter() and serviceLocalParameter() in a ATG servlet Bean? - atg

I am new to ATG Framework.
In the ATG Programming guide its explained that the serviceParameter() and serviceLocalParameter() are used to display the Open parameters.
And both parameters set by these 2 are visible in the
droplet
tag only.
What is the difference between the 2 methods.
Please explain.
Thanks in advance.

I believe this answer on the Oracle Discussion Forums answers it the best.
The difference lies in the scope of the visibility of the parameter inside the droplet tags, in particular if you have nested droplets.
It is further recommended that you use setLocalParameter and if you need to pass the parameter to other sections of the page, use the EL to do so.

Related

Create a Block with data from database in Sulu

I need to build a block with data from (Symfony) Entity.
For example a carousel with last 3 item/record from database.
This block can appear in more than just a page.
I know that I can use a custom controller but is that the best technical choice ?
Do i need "Smart content" ? Read the doc but it's not clear
How i can do that ?
Thanks in advance.
Using a twig extension or a controller would definitely be the easiest way, because no sulu knowledge is required for that.
But the sulu way of solving that problem would be a custom SmartContentDataProvider. There are two main advantages of this method:
The content editor can further filter the result (in your case probably sorting and limiting)
The result is also displayed in the admin interface (Otherwise it would just be shown in the preview)
Our community is usually using our Slack channel or GitHub Discussions for support questions. Your questions will probably be answered a lot faster there, because there we can better track them.

Sightly syntax to retrieve crx/de properties in jsp/html page

I would like to retrieve some properties e.g. jcr:created using Sightly or any related syntax for the panel component in AEM adaptive forms. 1
The previous Sighlty syntaxes that I have attempted to retrieve the crx/de properties include:
${properties.jcr:created}
${pageProperties\[jcr:created\].getTime.toString}
${guidePanel.jcr:created}
${resource.jcr:created}]
I have tried the following syntaxes but unable to retrieve the value from the property and in worst cases, the component may not be rendered on screen.
I have looked up on Adobe forum sites and past stackoverflow questions that other people may have asked. I have tried the solutions and given answers but was unable to achieve the result. I would greatly appreciate for any help or sharing of applicable knowledge if you have encountered similar issues or previously attempted to solve similar problems. Thank you!
You can always create Use class in Java or Javascript to access these properties, it's cleaner and testable. Better than that, you can use Sling Models which are more readable and easier to implement, here is a good presentation about it https://www.slideshare.net/accunitysoft/understanding-sling-models-in-aem
Properties of resources are readable without any extra definitions needed.
So you might want to check what resource is handled in your component by adding this:
${resource.path}
Then you can check the returned path in CRXDE if there really is a jcr:created property available at this path - which should be the case if you are accessing a resource that has a proper sling resource type. Then this call should give a valid return value:
${resource.path} ___ created:
${properties.jcr:created.getTime.toString}
If the path is not displayed as well, then it would help if you could post
the repo path of the content resource you are processing
the sling:resourceType
the path to the component's ht(m)l file that you are using

Keycloak templates available variables

I'am googling for a while in order to find a documentation of all available say "variables" I can use in the various Keycloak templates.
by variable I mean all the ${xxx.yyy} things I can use to inject some dynamic values inside the template.
Through the documentation I can find here and there some of them (like ${user.attributes} or ${url.resourcesPath}) but are there others than these ?
Does anyone have a reference link ?
Many Thanks
You can look for the template providers in Keycloak's code.
All the templates are "ftl" files filled with a map called "attributes". Keycloak has a couple of classes which fill those templates with Beans depending on the page or action as CharlyP mentioned. For example:
FreeMarkerEmailTemplateProvider class fills the email templates.
FreeMarkerLoginFormsProvider class fills the login templates.
I did not find any easy to use documentation but I found the Keycloak Javadocs which can be helpful when you look for the *Bean classes of this documentation. These classes seem to be the ones available in most of the templates. And their public methods will match the available properties you can use in the templates.
For example:
You want to know the properties available for the variable url you can check the class UrlBean in the documentation and you will find for example a method getLoginUrl. This means you can access the property url.loginUrl.
That's all I could find for the time being. Hope it will be helpful...

Difference between cq:include and sling:include

What is the difference between sling and cq includes and when should each one be used? I kinda find both solving the same purpose.
There is this link which recommends use of sling include and then there is cq doc which recommend use of cq include. As a programmer, under which situation will each of these includes be apt?
Usually if you are developing a CQ component, I'd follow the suggestion to use the cq:include. The sling:include has some additional parameter which can come handy if you need them, but I think in my 5 years as a CQ dev, I only had to use the sling:include once.
See sling documentation for the parameter: http://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html#include
If you have a component that has more than one jsp,to invoke the other jsp which doesnt match up with component name , sling include is helpful having replaceselector attribute having other jsp as a value

Google like autosuggest with Solr

I'm currently using Solr with Terms Component and Jquery Autosuggest which works quiet good. However, this construct is limited to one autosuggest word (it autocompletes only the first word). Is it possible to implement a Google like autosuggest with multiple words/terms so i can autocomplete multiple words?
I just wrote a blog post about different ways to make auto complete suggestions with Solr. It's basically a comparison of some different strategies, check it out, it might help.
If you want to make multiple terms suggestions, it turns out you should use, as already mentioned in the other answer you got, the Suggester component available in Solr starting from the 3.1 version. Since it has some limitations, you can also have a look at the ShingleFilterFactory, which generates token NGrams. It creates combination of tokens as a single token, that's useful to suggest multiple words.
You can also use SpellCheckComponent for better auto complete suggests.
See http://wiki.apache.org/solr/Suggester for details.
Edit:
Refer here for solr5 and above
Check this out, it might help
http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/
I worked out the same task, finally got solved using TermsComponent with multiple fields. check this link. http://lucene.472066.n3.nabble.com/auto-completion-search-with-solr-using-NGrams-in-SOLR-td3998559i20.html