Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/giosil/wportlet
Simple framework to build portlets like a webapp.
https://github.com/giosil/wportlet
java java-portlets liferay-portlet portlet portlets
Last synced: about 2 months ago
JSON representation
Simple framework to build portlets like a webapp.
- Host: GitHub
- URL: https://github.com/giosil/wportlet
- Owner: giosil
- License: apache-2.0
- Created: 2019-11-20T11:55:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-17T10:13:27.000Z (5 months ago)
- Last Synced: 2024-07-17T12:47:04.713Z (5 months ago)
- Topics: java, java-portlets, liferay-portlet, portlet, portlets
- Language: Java
- Homepage:
- Size: 3.31 MB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WPortlet
Simple framework to build portlets like a webapp.
## Example
```java
import javax.portlet.*;import org.dew.portlet.*;
public
class HelloAction implements IAction
{
public
Object action(String sAction, Parameters parameters, ActionRequest request, ActionResponse response)
throws Exception
{
if(parameters.isBlank("name")) {
throw new Exception(ResourcesMgr.getMessage(request, "error.name"));
}
String sName = parameters.getString("name");
return sName;
}
public
String view(String sAction, Parameters parameters, Object actionResult, RenderRequest request, RenderResponse response)
throws Exception
{
String sName = (String) actionResult;
String sHello = ResourcesMgr.getMessage(request, "hello", sName);
request.setAttribute("hello", sHello);
return "hello.jsp";
}
public String exception(String sAction, Parameters parameters, Exception actionException, RenderRequest request, RenderResponse response)
throws Exception
{
return null;
}
}
```## Setting Up JNDI in Liferay 7.4
In liferay/tomcat/conf/Catalina/localhost/ROOT.xml
```xml
```In 7.4 Liferay introduced the "Shielded Class Loader" in an effort to shield the webapp class loader from the OSGi container.
Before invoking the lookup:```java
Thread thread = Thread.currentThread();// Get the thread's class loader. You'll reinstate it after using
// the data source you look up using JNDI
ClassLoader origLoader = thread.getContextClassLoader();// get the shielded class loader
ClassLoader shieldedClassLoader = PortalClassLoaderUtil.getClassLoader();// get the webapp class loader from it
ClassLoader webappClassLoader = shieldedClassLoader.getClass().getClassLoader();// Set webapp class loader on the thread
thread.setContextClassLoader(webappClassLoader);
```## Build
- `git clone https://github.com/giosil/wportlet.git`
- `mvn clean install`## Contributors
* [Giorgio Silvestris](https://github.com/giosil)