Expand my Community achievements bar.

SOLVED

autocomplete in JSP - CQ on eclipse

Avatar

Former Community Member

Hi,

I am trying to achieve autocomplete feature on JSP in eclipse. I have followed the page http://dev.day.com/docs/en/cq/aem-how-tos/development/howto-develop-aem-projects-using-eclipse.html but still not able to accomplish. Here is a sample jsp I have prepared :

<%@ include file="/libs/foundation/global.jsp"%><% %><%@ page import="javax.jcr.*, org.apache.sling.api.resource.Resource, java.util.logging.Logger,java.util.Locale" %> <%@ taglib prefix="ex" uri="http://www.mercer.com/taglibs/mhrtaglib/1.0"%><% %><%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><% %><cq:setContentBundle/> <html> <head> <title>A sample custom tag</title> <cq:includeClientLib css="etc.designs.mercer.clientlibs"/> <!--  <script src="etc/designs/mercer/clientlibs/js/vendor/custom.modernizr.js" type="text/javascript"/>   --> </head> <body> <ex:Hello/> <% Locale pageLocale = currentPage.getLanguage(false); %><br> <%= slingRequest.getResourceBundle("insights",pageLocale).getString("hello") %>  <br>   <br> <%= slingRequest.getResourceBundle("solutions",pageLocale).getString("hello") %> </body> </html>

These are the following errors and warning I am getting :

a) warning  "Unknown tag (cq:setContentBundle)".

b) currentPage cannot be resolved

c) slingRequest cannot be resolved

d) warning Unknown tag (cq:includeClientLib).

Below given are the dependencies in my pom.xml file:

<dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>mercer-cq-package-bundle</artifactId> <version>${project.version}</version> </dependency> <!-- dependency defined by AnkitC::Start --> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId> <!-- javax.jcr --> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.api</artifactId> </dependency> <dependency> <groupId>com.day.cq</groupId> <artifactId>cq-commons</artifactId> <!-- com.day.cq.commons --> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-commons</artifactId> <!-- com.day.cq.wcm.commons --> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-api</artifactId> <!-- com.day.cq.wcm.api --> </dependency> <dependency> <groupId>com.day.commons</groupId> <artifactId>day-commons-jstl</artifactId> <!-- javax.servlet.jsp.jstl.core --> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-taglib</artifactId> <!-- com.day.cq.wcm.tags --> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId> <!-- org.apache.sling.scripting.jsp.taglib --> </dependency> <dependency> <groupId>com.adobe.granite</groupId> <artifactId>com.adobe.granite.xssprotection</artifactId> <!-- com.adobe.granite.xss --> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-core</artifactId> <!-- com.day.cq.wcm.core.components --> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <!-- org.apache.commons.lang3 --> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> <!-- dependency defined by AnkitC::Start --> </dependencies>

Not sure, what exactly I am missing. Some jar files in my local.

Any help is appreciated.

Thanks in advance,

Ankit

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

What I sometimes do is to reference the global.jsp via ../../ instead of /libs/ etc.

Can you try this?

What I sometimes do is to reference the global.jsp via ../../ instead of /libs/ etc.

Can you try this?

 

This did the trick.  Thanks for the response.

Ankit

View solution in original post

7 Replies

Avatar

Correct answer by
Former Community Member

What I sometimes do is to reference the global.jsp via ../../ instead of /libs/ etc.

Can you try this?

What I sometimes do is to reference the global.jsp via ../../ instead of /libs/ etc.

Can you try this?

 

This did the trick.  Thanks for the response.

Ankit

Avatar

Employee

Does /libs/foundation/global.jsp resolve?

In other words, do you have a copy of it in your project workspace?

Avatar

Level 1

Please refer "http://dev.day.com/docs/en/cq/5-5/developing/developmenttools/developing_with_eclipse.html"

 

You should copy jar files from repository(http://localhost:4502/crx/repository/crx.default/libs/) into a folder in your system.
 

Now

In your project goto buildpath>>library>>Add External Jars add the jars

then you will not get the errors.

Avatar

Former Community Member

Hi Bruce,

I just copied global.jsp from /libs/foundation. But it is still giving errors. However, I have one more thought going on in my mind. Since the APIs used here in this code are all CQ related and this is more of an environment related issue, and hence should work fine in your regular CQ environment. What is your take on this ?

Thanks,

Ankit

Avatar

Level 5

If eclipse can find out /libs/foundation/global.jsp then jsp autocomplete should work. Some time path is not expected under jcr_root but at root project level. You can right click on your jsp file and select validate to find exact path where you want to put your global.jsp once placed right click again and select validate. 

Hope this will help.

 

Yogesh

Avatar

Former Community Member

Thanks for you response Yogesh. I just validated the jsp file and getting an error "Fragment "/apps/mercer/components/common/global.jsp" was not found at expected path /MMC/apps/
 mercer/components/common/global.jsp"

Is there anyways I can fix this.

I am also getting error "currentPage cannot be resolved" on the below lines:

Locale pageLocale = currentPage.getLanguage(false); 
slingRequest.getResourceBundle("insights",pageLocale).getString("hello")

Any help is appreciated.

Thanks.
 

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----