[JBoss Portal] - Re: Setting Portlet Preferences in Jboss Portal
by piergiorgiolucidi
To manage preferences in your portlet you need to add preferences in your portlet.xml in this way:
| <portlet>
| <portlet-name>YourPortlet</portlet-name>
| <portlet-class>org.yourcompany.portlet.content.YourPortlet</portlet-class>
| <supports>
| <mime-type>text/html</mime-type>
| <portlet-mode>VIEW</portlet-mode>
| </supports>
| <portlet-info>
| <title>Your Portlet Title</title>
| </portlet-info>
| <portlet-preferences>
| <preference>
| <name>numberContactPerPage</name>
| <value>10</value>
| </preference>
| </portlet-preferences>
| </portlet>
|
Then in your portlet you can use this snippet:
| public void processAction (ActionRequest request, ActionResponse
| actionResponse)
| throws PortletException, java.io.IOException {
| PortletPreferences pref = request.getPreferences();
| pref.setValue("15",request.getParameter("numberContactPerPage"));
| pref.store();
| actionResponse.setPortletMode(PortletMode.VIEW);
| actionResponse.setRenderParameters(request.getParameterMap());
| }
|
Hope this helps.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4214599#4214599
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4214599
15 years, 10 months
[JBoss Portal] - WSRP resources URLs
by cpage
I have some questions about URLs of resources with remote portlet.
I use JBoss 4.2.3 + JBossPortal 2.6.6.
In the WSRP primer we can read :
anonymous wrote : Producers may not offer a web interface (i.e., offer http/https ports) for content
So I suppose the consumer should rewrite all URLs to refer to him but it seems not the case with JBossPortal.
For example, this is the differences between local et remote portlet HTML code rendering :
| local :
| <img src="/myportlet/transparent.gif" style="background:url('/myportlet/creer.png')!important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=scale,src='/myportlet/creer.png');" />
|
| remote :
| <img src="http://localhost:8180/myportlet/transparent.gif" style="background:url('/myportlet/creer.png')!important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=scale,src='http://localhost:8180/myportlet/creer.png');" />
In this example, for the remote portlet, some URLs refers to the producer (localhost:8180) and others (in CSS) refers to relative URLs (that do not exist in the consumer).
What is the good practice with resources in remote portlet ?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4214595#4214595
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4214595
15 years, 10 months
[JBoss Portal] - Re: unable to see java portlet instence
by piergiorgiolucidi
I think it could be depend on settings on your portlet-instances.xml file.
If you have declared "if-exists" tag for this portlet in your portlet-instances.xml in this way:
| <if-exists>overwrite</if-exists>
| <instance>
| <instance-id>YourPortletInstance</instance-id>
| <portlet-ref>yourApp.yourPortlet</portlet-ref>
| </instance>
|
You are telling the container to destroy any existing object and create a new one.
If would you like the container retains any existing copy and creates a new instance, then you must set "keep" as value of this tag, in this way:
| <if-exists>keep</if-exists>
| <instance>
| <instance-id>YourPortletInstance</instance-id>
| <portlet-ref>yourApp.yourPortlet</portlet-ref>
| </instance>
|
Try this ;)
Hope this helps
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4214585#4214585
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4214585
15 years, 10 months
[EJB/JBoss] - How can i stop ejb timer ???
by Nouredine13
Hello,
i have the following problem:
I can not kill an ejb timer after the call unregisterTimer method, and the timer is still active even after the ejb is undeployed.
the source code of my bean is here under :
Code:
package com.test.timer;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.ejb.EJBException;
import javax.ejb.Local;
import javax.ejb.NoSuchObjectLocalException;
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerHandle;
import javax.ejb.TimerService;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.log4j.Logger;
@Local( ITimerManagerLocal.class)
@Remote(ITimerManagerRemote.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
@Stateless( name = "NotifyExpiration", mappedName="NotifyExpirationRemote")
public class TimerManagerBean implements ITimerManagerLocal, ITimerManagerRemote {
private static final Logger logger = Logger.getLogger ( "EXPIRATION_SERVICE");
@Resource
private SessionContext sessionContext;
@Resource
private TimerService timerService;
//--------------------------------------------------------------------------
// Methods
//--------------------------------------------------------------------------
@PreDestroy
public void unregisterTimer() throws NamingException {
logger.info( "NOTIFY TIMEOUT UNREGISTER");
Context ctx = new InitialContext();
try {
TimerHandle handle = (TimerHandle) ctx.lookup( "TIMER_JNDI_NAME");
ctx.unbind("TIMER_JNDI_NAME");
if (handle != null){
try {
Timer expirationTimer = handle.getTimer();
if (expirationTimer != null){
expirationTimer.cancel();
}
} catch (NoSuchObjectLocalException e) {
logger.warn( "UNABLE TO UNREGISTER TIME OUT", e);
} catch (IllegalStateException e) {
logger.warn( "UNABLE TO UNREGISTER TIME OUT", e);
} catch (EJBException e) {
logger.warn( "UNABLE TO UNREGISTER TIME OUT" , e);
}
}
} catch (Throwable thre){
logger.warn( "UNABLE TO UNREGISTER TIME OUT", thre);
return;
}
}
public void registerTimer() throws NamingException {
unregisterTimer();
int delai = 10 * 1000;
Timer expirationTimer = createTimer( delai);
Context ctx = new InitialContext();
ctx.bind("TIMER_JNDI_NAME", expirationTimer.getHandle());
if (logger.isInfoEnabled()){
logger.info("TIMER REGISTERED " + expirationTimer.getNextTimeout().getTime());
}
}
private Timer createTimer( int delai)
{
try {
return sessionContext.getTimerService().createTimer(delai, delai, null);
} catch( Throwable thr) {
return timerService.createTimer (delai, delai, null);
}
}
@Timeout
//(a)TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void timedOut(Timer obj)
{
try {
if (logger.isDebugEnabled()){
logger.debug(
String.format("TIMER WAKEUP at: " + System.currentTimeMillis()));
}
logger.debug("do something...");
}catch (RuntimeException e) {
logger.debug( "TIMER WAKEUP FAILS");
}
}
}
so first i register the timer by calling registerTimer() method, and i wont to kill it by calling unregisterTimer() method. but this does not work, and the timer remains active even after the bean is undeployed.
If somme one has an idea or workaround to solve this problem ?
Thank's a lot.
Regard's.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4214583#4214583
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4214583
15 years, 10 months