0

THIS PROBLEM IS ALREADY SOLVED IN THE MYFACES 2.1 IMPLEMENTATION

I have a link which passes an Integer parameter properly like this:

<h:link outcome="/process/createProcess">
    <f:param name="id" value="#{process.idprocess}" />
    Edit
</h:link>

It goes to "createProcess.xhtml?id=21" properly, and I have this code in the request scope backing Bean createProcess:

@ManagedProperty(value="#{param.id}")
private Integer idProcess;

private Process newProcess;

@PostConstruct
public void init()
{
    log();
    if (idProcess!=null)
        newProcess = Dao.getProcessDAO().get(idProcess);
    else
        newProcess = new Process();
}

I've notice that idProcess is always null. After debugging I realized that setIdProcess method is called AFTER @PostConstruct.

I understand that injection is done just after the construction of the bean and all the managedProperties are available in @PostConstruct.

What am I missing?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Vic
  • 632
  • 6
  • 15
  • This should not happen. Cannot reproduce this on Mojarra 2.1.1 as well. What JSF impl/version exactly are you using? – BalusC Jul 07 '11 at 18:53
  • @BalusC Apache MyFaces 2.0 on Tomcat 7.0. I've read your articles in your blog and your answers here where you said that the injected variables should be available in @postconstruct, but not for me... – Vic Jul 07 '11 at 21:34
  • I don't do MyFaces. In future MyFaces questions, please tag as such. I've added it on this question. All I can suggest is to try Mojarra. Even though it's just for testing to exclude one and other so that you can writeup a proper issue report to the MyFaces guys. – BalusC Jul 07 '11 at 21:36
  • I updated the project to MyFaces 2.1 and now it inject first the variables and then call the @PostConstruct. Finally it was a bug already fixed in the lastest version (June 11). @BalusC Thanks for your advices, i'll take that in account. – Vic Jul 10 '11 at 00:35

1 Answers1

0

Just for reference, I think the issue in this post is MYFACES-3116, with was already fixed at , so 2.0.6, 2.1.0 and upper versions does not have it.

lu4242
  • 2,318
  • 1
  • 15
  • 15