掲示板
Overriding Core JSP not working
6年前 に Jacopo Bartolini によって更新されました。
Overriding Core JSP not working
Junior Member 投稿: 28 参加年月日: 17/01/19 最新の投稿
Hi, I would like to override page.jsp in the logo-selector tag, to fix bug LPS-66752. I've followed the tutorial at https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/overriding-core-jsps, but it's not working properly. Any help would be appreciated.
JSP path: src/main/resources/META-INF/jsps/html/taglib/ui/logo_selector/page.jsp
Here's my Java class:
And in the bnd.bnd I've only put the Bundle-SymbolicName and the Bundle-Version.
Thanks in advance.
JSP path: src/main/resources/META-INF/jsps/html/taglib/ui/logo_selector/page.jsp
Here's my Java class:
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import com.liferay.portal.deploy.hot.CustomJspBag;
import com.liferay.portal.kernel.url.URLContainer;
@Component(
immediate = true,
property = {
"context.id=LogoSelectorCustomJspBag",
"service.ranking:Integer=100"
}
)
public class LogoSelectorCustomJspBag implements CustomJspBag {
@Override
public String getCustomJspDir() {
return "META-INF/jsps/";
}
@Override
public List<string> getCustomJsps() {
return _customJsps;
}
@Override
public URLContainer getURLContainer() {
return _urlContainer;
}
@Override
public boolean isCustomJspGlobal() {
return true;
}
@Activate
protected void activate(BundleContext bundleContext){
_bundle = bundleContext.getBundle();
_customJsps = new ArrayList<>();
Enumeration<url> entries = _bundle.findEntries(getCustomJspDir(), "*.jsp", true);
int i = 0;
while (entries.hasMoreElements()) {
URL url = entries.nextElement();
System.out.println(i + ") " + url.getPath());
_customJsps.add(url.getPath());
}
}
private Bundle _bundle;
private List<string> _customJsps;
private final URLContainer _urlContainer = new URLContainer() {
@Override
public URL getResource(String name) {
System.out.println("COSA FANNO" +_bundle.getEntry(name).toString());
return _bundle.getEntry(name);
}
@Override
public Set<string> getResources(String path) {
Set<string> paths = new HashSet<>();
for(String entry : _customJsps) {
if (entry.startsWith(path)) {
paths.add(entry);
}
}
return paths;
}
};
}
</string></string></string></url></string>
And in the bnd.bnd I've only put the Bundle-SymbolicName and the Bundle-Version.
Thanks in advance.
6年前 に Jacopo Bartolini によって更新されました。
RE: Overriding Core JSP not working (回答)
Junior Member 投稿: 28 参加年月日: 17/01/19 最新の投稿
Ok, I solved it. I simply added "context.name" in my java class, and also removed Bundle-SymbolicName and added -sources: true in my bnd.bnd. Hope will help someone.
6年前 に Chenna Yon によって更新されました。
RE: Overriding Core JSP not working
New Member 投稿: 7 参加年月日: 15/01/08 最新の投稿
Thanks for you sharing, could you please guide me detail how to add the "context.name" in your class?
6年前 に Olaf Kock によって更新されました。
RE: Overriding Core JSP not working
Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿Chenna Yon:
Thanks for you sharing, could you please guide me detail how to add the "context.name" in your class?
Check the sample code here
6年前 に RAVI RAJAMANI によって更新されました。
RE: Overriding Core JSP not working
Regular Member 投稿: 123 参加年月日: 14/12/07 最新の投稿Olaf Kock:
Chenna Yon:Thanks for you sharing, could you please guide me detail how to add the "context.name" in your class?
Check the sample code here
I have followed same blade sample, even though its not relecting
Note:- I have downloaded sample code from git and deployed its not working.
Regards,
Ravi Rajamani
6年前 に Olaf Kock によって更新されました。
RE: Overriding Core JSP not working
Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿RAVI RAJAMANI:
its not working.
could you be a bit more specific?
6年前 に Chenna Yon によって更新されました。
RE: Overriding Core JSP not working
New Member 投稿: 7 参加年月日: 15/01/08 最新の投稿
Thank Olaf Kock,
Let me try.
Let me try.