JSF 2.0 driven portlet in Websphere - how to implement commandLinks

744 Views Asked by At

I know how to create JSF 2.0 servlets and I know how to create portlets, but I have problems combining both technologies. My JSF portlet works well until I have to call methods of my backing beans via <h:commandLink />. When I click those links the current page is reloaded and no method is invoked. I think my application needs some extra configuration. What needs to be done in order to get a command link like this to work:

<h:commandLink action="#{backingBean.doSomething}" />

Note that I'm using a WebSphere 8 portal server which provides a JSF 2.0 portlet bridge.

EDIT

I see a basic conflict here:

  • portlet API is responsible for generating URLs - generates valid portal-URLs
  • JSF is responsible for generating URLs - generates valid JSF-URLs

My managed beans are configured using annotations:

@ManagedBean(name = "backingBean")
@ViewScoped
public class entryEditController
{
     public String doSomething()
     {
         return "result.xhtml";
     }
}

This is my faces-config.xml

  <?xml version="1.0" encoding="UTF-8"?>
  <faces-config
          xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
          version="2.0">
      <application>
          <view-handler>com.ibm.faces20.portlet.FaceletPortletViewHandler</view-handler>
          <el-resolver>com.ibm.faces20.portlet.PortletELResolver</el-resolver>
          <resource-handler>com.ibm.faces20.portlet.httpbridge.PortletResourceHandler</resource-handler>
      </application>
  </faces-config>
1

There are 1 best solutions below

0
On BEST ANSWER
  1. Update to WAS 8.0.0.8
  2. If your bean is @SessionScoped or @ViewScoped you have to add this to your web.xml:

    <context-param>
       <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
       <param-value>false</param-value>
    </context-param>
    
  3. Before step 2 I added a new command-button with an invalid action-value. This leads to a validation error. On validation errors the command is not executed => Make sure that there aren't any validation errors, for instance by adding a <h:messages /> to your template
  4. Read this answer: https://stackoverflow.com/a/2120183/395879