On PAGE A
is a table with some data from the database.
by clicking on a row, the page will be forwarded to PAGE B
and in the controller the entity will be injected
@DataModelSelection(value = ENTITY_LIST_NAME)
@Out(value = ENTITY_NAME, scope = ScopeType.CONVERSATION, required = false)
private Entity entity;
this works as it should.
The problem is, that our users seems to use bookmark for PAGE B
, so the entity will never be injected because they never visited PAGE A
so they always throw this exception
@In attribute requires non-null value
Is there a global function to catch all @In attribute requires non-null value
exceptions and forward the user to PAGE C
(startpage)?
(of course i can catch this execption on PAGE B
but this happens not only on one page, we want to handle this exception on every page)
we are using: jboss5 + jsf 1.2 + seam 2
UPDATE after the answer of EmirCalabuch:
I also tried the hint from EmirCalabuch with:
<page conversation-required="true" no-conversation-view-id="PageC.xhtml" />
but the problem is, that the conversation is alive at this moment, to this forwarding to pageC
never happens...
i also made in the page.xml
of this page something like:
<action execute="#{controller.checkIfEntityIsSet()}" />
<navigation>
<rule if-outcome="HOME">
<redirect
view-id="/pages/home.xhtml"
/>
</rule>
</navigation>
and in my Controller.java
i have somthing like this:
public String checkIfEntityIsSet(){
if(getEntity() == null){
return "HOME";
}
return "";
}
but this checkIfEntityIsSet()
is never called, because the @In attribute requires non-null value
is thrown before... so this was not a help at all...
i managed it now different:
in the Controller.java
i have for the initialization something like this:
@Create
public void initialize() throws MissingMyEntityException {
if(qualifiedCustomer == null){
throw new MissingMyEntityException("something wrong");
}
....
}
my MissingMyEntityException.java
looks like this:
public class MissingMyEntityException extends Exception {
private static final long serialVersionUID = 8640645441429393157L;
public MissingMyEntityException(String message) {
super(message);
}
}
and in the pages.xml
i have the exception handler like this:
<exception class="com.dw.companyName.view.xyz.exception.MissingMyEntityException">
<redirect view-id="/pages/home.xhtml">
<message>something went wrong</message>
</redirect>
</exception>
and this fixed the problem.
but thanks for your help, but it was not working your way :(