f:validateLongRange instantiating a Bean where it should not

I have the following validator: The validator belongs to a JSF page whose backing bean is ViewScoped. The relevant code snippets: public Integer getMaxOrder() maxOrder = selectedFileFormat.getColumnList().size(); return maxOrder; _ public Integer getMinOrder() if (getIsCode()) minOrder = 1; else minOrder = 2; return minOrder; }_ public String getValOrder() valOrder = “Range of …

via Java Application Development Tutorial » Search Results » ajax:

f:validateLongRange instantiating a Bean where it should not

I have the following validator:


The validator belongs to a JSF page whose backing bean is ViewScoped.
The relevant code snippets:
public Integer getMaxOrder()

maxOrder = selectedFileFormat.getColumnList().size();

return maxOrder;
_
public Integer getMinOrder()

if (getIsCode())

minOrder = 1;

else

minOrder = 2;

return minOrder;
}_
public String getValOrder()

valOrder = “Range of ” + minOrder + ” to ” + maxOrder;

return valOrder;
_
There is a cancel button on my page:

_
Whose action:
public String cancel()

Integer theFormatId = selectedFileFormat.getId();

return “fileFormatEdit.xhtml”
_
My Question: why is the postConstruct of my bean being called after pressing the cancel button? I found that the cause is the f:validateLongRange but why is it instantiating a new columnEdit bean?
…………………………………..

I think it’s because you’re are specifically defining the next view to navigate by return “fileFormatEdit.xhtml” ?
If you mean to return to the same page, try changing to return null (meaning no navigation, and make use the current active view).
Or simply change the action method definition to public void cancel(), where you dont have to return anything.

For more info: f:validateLongRange instantiating a Bean where it should not

Java Application Development Tutorial » Search Results » ajax

f:validateLongRange instantiating a Bean where it should not

Share this post:

Related Posts

Leave a Comment