Could this have to do with the fact the portal container is going to
namespace you session bean?  In websphere portal it adds a prefix to
the attribute name to sort of carve up the httpsession among portlets.

Then your ajax request is coming in to the faces servlet where there
is no namespace involved.  So in that case you might get the bean
created twice.

I think that the myfaces impl only maps jsf session beans to the
PORTLET session scope.  But there really is no reason you couldn't
change that to use the APPLICATION session scope instead.

javax.portlet.PortletSession

setAttribute(java.lang.String name, java.lang.Object value, int scope)
         Binds an object to this session in the given scope, using
the name specified.

setAttribute(java.lang.String name, java.lang.Object value)
         Binds an object to this session under the PORTLET_SCOPE,
using the name specified.

The key would be to override the myfaces portlet external context to
use APPLICATION_SCOPE for the scope parameter.  Thats just my guess
for sharing beans between portlets and servlets.







On 4/24/07, Gary VanMatre <[EMAIL PROTECTED]> wrote:
>From: "Strittmatter, Stephan" <[EMAIL PROTECTED]>
>
> Hm, but how to get ExternalContext.encodeResourceURL within Jscript?
> I tried to put an outText with this value calculated by my managed bean,
> but the outtext is rendered in different place not within the script.
>

The URL would have to be built when the page is rendered on the server.
Maybe you could use a hidden attribute in the form.

<h:inputHidden id="remoteUrl" value="#{mybean.getRemoteUrl}"/>

Let the backing bean add the encoding.

public String getRemoteUrl() {
      FacesContext context = FacesContext.getCurrentInstance();
      return context.getApplication().getViewHandler().getResourceURL(context, 
"dynamic/userBean/method.faces");
}

Then use the hidden attributes value in script.


Gary

> -----Original Message-----
> From: Gary VanMatre [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 23, 2007 6:50 PM
> To: user@shale.apache.org
> Subject: RE: [shale-remote] SesionBeans in MyFaces/Portlet Application
>
> >From: "Strittmatter, Stephan"
> >
> > If the Bean is in session scope I would expect only one bean per
> session
> > or am I wrong?
> >
>
> Session scope is defined to the web container by the "jsessionid". Does
> your remote request contain the jsessionid as a query parameters? Try
> using the ExternalContext.encodeResourceURL method to build the URL used
> by the remoting call. That's probably the only option if this is truly
> a portlet.
>
>
> > -----Original Message-----
> > From: Hermod Opstvedt [mailto:[EMAIL PROTECTED]
> > Sent: Monday, April 23, 2007 4:53 PM
> > To: user@shale.apache.org
> > Subject: SV: [shale-remote] SesionBeans in MyFaces/Portlet Application
>
> >
> > Hi
> >
> > Indeed - Once going in on the post, and then again going out on the
> > render
> > response.
> >
> > Hermod
> >
> > -----Opprinnelig melding-----
> > Fra: Strittmatter, Stephan [mailto:[EMAIL PROTECTED]
> > Sendt: 23. april 2007 16:50
> > Til: user@shale.apache.org
> > Emne: [shale-remote] SesionBeans in MyFaces/Portlet Application
> >
> > Hi all,
> >
> > I have made some small tests using shale-remote to make AJAX updates
> > within my MyFaces-Portlet, but I found, that the session scoped
> > ManagedBean is instantiated twice!
> > I use the:
> > * shale-remote of SVN (last week)
> > * Apache Portlet bridge 1.0
> > * MyFaces/Tomahawk 1.1.5
> >
> > I think, there are created two different contexts but not shure. Has
> > already had someone this problem?
> >
> > Regards,
> >
> > Stephan
> >
> >

Reply via email to