3

I have a xhtml page where i have an outputlink with f:param

<h:outputLink value="#{formService.getStartFormData(v_process.id).formKey}"> Start <f:param name="processDefinitionKey" value="#{v_process.key}"></f:param> </h:outputLink>

in the target page , i have view param

f:metadata>
        <!-- bind the key of the process to be started -->
        <f:viewParam name="processDefinitionKey" value="#{processList.processDefinitionKey}"/> 

    </f:metadata>

my bean is

@Named
@RequestScoped
public class ProcessList{

private String processDefinitionKey ; 

@Inject
private RepositoryService repositoryService;

@Produces
@Named("processDefinitionList")
public List<ProcessDefinition> getProcessDefinitionList() {
return repositoryService.createProcessDefinitionQuery()
        .list();
}

public void setProcessDefinitionKey(String processDefinitionKey1) {
  System.out.println("setProcessDefinitionKey "+processDefinitionKey1);
this.processDefinitionKey = processDefinitionKey1;
}

public String getProcessDefinitionKey() {
  System.out.println("getProcessDefinitionKey______ "+processDefinitionKey);
return processDefinitionKey;
}


}

processDefinitionKey is null , the setter is not called , what's wrong ? are there any configurations in web.xml or faces-config.xml to add? in the same project i work with primefaces and spring security

this is the whole page

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/WEB-INF/templates/template.xhtml">

<ui:define name="metadata">
    <f:metadata>
        <!-- bind the key of the process to be started -->
        <f:viewParam name="processDefinitionKey" value="#{processList.processDefinitionKey}" />
    </f:metadata>
</ui:define>

<ui:define name="content">      

Thank you for replying , please this did not work

niamat
  • 31
  • 3
  • I think you are missing the setter for this method: `public List getProcessDefinitionList()`. Can you try that? – Cacho Santa Jun 29 '12 at 16:08
  • @cacho: Why exactly would a setter for that property be necessary in this particular case? – BalusC Jun 29 '12 at 16:59
  • @BalusC: Because I think that code represents a JSF Java Bean, consequently, it needs to have a getter/setter for each property, am I right? – Cacho Santa Jun 29 '12 at 18:30
  • 1
    @cacho: No. Setters are not necessary for output-only values. Besides, if the missing setter was really the cause, you would have gotten a `PropertyNotWritableException`, but this is far from the cause here. – BalusC Jun 29 '12 at 18:33
  • I have edited my question , a have f:metadata in my page , not in template page .config files or spring security, primefaces or jsf version can have an impact or not? thank you for reply , please help if you have an idea – niamat Jun 29 '12 at 19:07

2 Answers2

2

Try to change the namespaces like posted already here. In my case (glassfish 4.0) and in the case linked, it had to be

xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"

but try

xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"

Which worked on Tomcat for me.

If someone has an idea why this is this way, I would be happy to here. Second variant should be the correct one what I read here.

Community
  • 1
  • 1
timmornYE
  • 708
  • 2
  • 8
  • 22
1

It's a JEE7 bug. https://java.net/jira/browse/JAVASERVERFACES-2868 As a work as a workaround I put:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:oldf="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/template.xhtml">
<oldf:metadata>
    <oldf:viewAction action="#{chooseRoleBean.init()}" />
</oldf:metadata>