0

I have a list of objects and each entry has a link to the object's detail view. The code for the link is

<h:link outcome="#{detailViewPageName}" rendered="#{listRow.rowData.dbId != null}">
     <f:param name="faces-redirect" value="true" />
     <f:param name="phoneNr" value="#{listRow.rowData.phoneNr}" />
     <f:param name="fromDate" value="#{listRow.rowData.fromDate}" />
     <f:param name="toDate" value="#{listRow.rowData.toDate}" />
       #{listRow.rowData.phoneNr == "-1" ? msg.subscriptionPhoneNumberUnknown : listRow.rowData.phoneNr}
</h:link>

and an ex. of a resulting link is:

http://bla-bla.bla/cmn-web/view/cmn/billDetailView.xhtml?faces-redirect=true&phoneNr=41798009726&fromDate=2013-01-01&toDate=2013-01-31

The bean for the detail view has the params defined with getters and setters and the page has the f:viewparam defined too:

<ui:define name="metadata">
   <f:metadata>
      <f:viewParam name="phoneNr" value="#{billDetailController.model.phoneNr}"/>
      <f:viewParam name="fromDate" value="#{billDetailController.model.fromDate}"/>
      <f:viewParam name="toDate" value="#{billDetailController.model.toDate}"/>

      <f:event listener="#{billDetailController.selectData}" type="preRenderView" />
   </f:metadata>
</ui:define>

The problem is that the values in the detail bean are never set...

Now what I see with the debugger is that after clicking the link (and I assume before the page is loaded and the selectData method is called) the parameters' getters are called, but not the setters.

The bean is ManagedBean and CustomScoped.

What do I miss?

EDIT:

Bean (a very easy one):

@ManagedBean( name = "billDetailModel" )
@ViewScoped
public class BillDetailModel extends DetailModel
{
  private String    phoneNr;
  private Date  fromDate;
  private Date    toDate;

  public String getPhoneNr()
  {
    return phoneNr;
  }

  public void setPhoneNr( String phoneNr )
  {
    this.phoneNr = phoneNr;
  }

  public Date getFromDate()
  {
    return fromDate;
  }

  public void setFromDate( Date fromDate )
  {
    this.fromDate = fromDate;
  }

  public Date getToDate()
  {
    return toDate;
  }

  public void setToDate( Date toDate )
  {
    this.toDate = toDate;
  }
}
Francesco
  • 2,350
  • 11
  • 36
  • 59
  • So difficult to test with the provided code. What happens if you change your bean to `@ViewScoped`? – Aritz Dec 02 '13 at 12:24
  • With `@ViewScoped` is the same... – Francesco Dec 02 '13 at 12:58
  • 1
    Make a habit of always having a `` somewhere in the view. Otherwise you never know what you miss. – BalusC Dec 02 '13 at 13:12
  • @BalusC As always the right tip... `Conversion Error setting value '2013-01-01' for 'null Converter'. Conversion Error setting value '2013-01-31' for 'null Converter'.` – Francesco Dec 02 '13 at 13:19

1 Answers1

1

maybe check if there are any ConverterExceptions during JSFs Update-Phase. If you e.g. try to set the date into a getter/setter expecting a Date- or Calendar-Object, this might not work without an proper DateConverter inbetween.

Hope that helps...

L-Ray
  • 1,637
  • 1
  • 16
  • 29
  • 1
    If the getter/setter expects an other object like java.util.Date or java.util.Calendar AND there is a fitting Faces-Converter in place for this given class (`@FacesConverter(forClass=YourClassHere.class)`). it gets automatically converted. Because you didn't post the managed bean part, I just wanted to be sure you expect an String there... :-) – L-Ray Dec 02 '13 at 12:59
  • You're right, the bean expects two dates and a string (see edit in the question). I'll try to add the converter and see if then it works... – Francesco Dec 02 '13 at 13:06