0
votes

I have some code generated by netbeans wizard 'JSF pages from entity classes'. For those who don't use netbeans I will briefly describe what the wizard does. It creates a JSF page List.xhtml which contains a datatable with a fixed size of ten rows and two commandlinks for scrolling its content (prev 10 and next 10). The JSF page uses a managedbean with session scope and the above mentioned commandlinks return the String 'List'. If I change the managed bean scope to @viewscoped it is re-created every time I push a commandlink. According to me it is a weird behavior because the view actually doesn't change (it always List.xhtml ) and I would have expected a smarted view scope mechanism.

I then changed the action associated to the commandlinks with a new one which does the same things but returns void. Now the @viewscope mechanism works well but I'm not sure it is correct to use an action method with a signature like this

public void doSomething()
// instead of
public String doSomething()

My concern is that a different JSF implementation can act in an impredictable way with that kind of actions.

Thanks Filippo

1

1 Answers

0
votes

What do you return in public String doSomething()?

If you return null (or an empty String) it should not re-create the view.

If you return a navigation case then the view is re-created, regardless whether it is the same that you are currently in.