[JBoss Seam] - @Restrict and redirect.captureCurrentView
by fmeystre
I try to use the built-in security handling to redirect user to the page she originally requested after the login.
I works fine when I'm using login-required="true" in pages.xml but the problem is when I'm using @Restrict("#{identity.loggedIn}") in the class. When the annotations is used, the login page is shown but after login the page is reloaded (instead of the originally requested). And on the JBoss Console I can see an Exception: javax.faces.el.EvaluationException: Exception while invoking expression #{commandeService.commander} ........... Caused by: org.jboss.seam.security.NotLoggedInException
I'm doing something wrong ?
here is my files :
pages.xml :
<pages no-conversation-view-id="/home.xhtml"
login-view-id="/login.xhtml">
<page view-id="*">
...
<navigation from-action="#{commandeService.commander(panier)}">
<redirect view-id="/commande.xhtml">
...
<page view-id="/commande.xhtml" login-required="true">
...
<redirect view-id="/login.xhtml">
#{messages.NotLoggedIn}
components.xml:
...
...
Java class, session bean with restricted method/class:
@Stateful
@Scope(CONVERSATION)
@Name("commandeService")
@Restrict("#{identity.loggedIn}")
public class CommandeServiceBean implements CommandeService{
@In(required=false)
private User user;
...
@PersistenceContext
private EntityManager em;
@Begin(join=true)
public void commander(Panier panier) throws PoidsMaxException, NotLoggedInException {
...
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083871#4083871
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083871
18 years, 9 months
[JBoss Seam] - Single Inheritance / ConstraintViolationException / Postgre
by toni
Hi,
using a single table inheritance strategy with postgres 7.3 always causes a ConstraintViolationException when I try to merge the changes.
I first create a new enity bean, which works. Then I add it to a OneToMany collection of another entity bean and try to merge the change. This is when I get a ConstraintViolationException.
Here is the setup:
| @Entity
| @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
| public class Person implements Serializable
| {
| @Id
| @GeneratedValue(strategy = GenerationType.IDENTITY)
| long id;
| ..
| }
|
| @Entity
| @Name("junior")
|
| public class Junior extends Person
| {
| ...
| }
|
| @Entity
| @Name("school")
|
| public class School implements Serializable
| {
| @Id
| @NotNull
| @Length(min = 5, max = 40)
| String schoolName
|
| @OneToMany(cascade = {CascadeType.ALL})
| List<Juniors> juniors = new ArrayList<Juniors>();
|
| @OneToMany(cascade = {CascadeType.ALL})
| List<Softmore> softmores = new ArrayList<Softmore>();
|
| @OneToMany(cascade = {CascadeType.ALL})
| List<Senior> seniors = new ArrayList<Senior>();
| ...
|
The following code always throws a ConstraintViolationException
| // works
| entityManager.persist(junior);
| // this causes a contraint violation
| school.getJuniors().add(junior);
| school = entityManager.merge(rewriteConfiguration);
|
The reason why this happens, is because the columns of the database table, which keeps track of the OneToMany relationships are all defined to be NOT NULL. Here comes the table:
|
| school_schoolname character varying(40)
| NOT NULL
|
| juniors_id bigint
| NOT NULL
|
| softmores_id bigint
| NOT NULL
|
| seniors_id bigint
| NOT NULL
|
|
However, all those columns SHOULD be nullable, but hibernate does not set them up like this. How can I make sure hibernate does this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083865#4083865
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083865
18 years, 9 months
[EJB 3.0] - Single Inheritance / ConstraintViolationException / Postgre
by toni
Hi,
using a single table inheritance strategy with postgres 7.3 always causes a ConstraintViolationException when I try to merge the changes.
I first create a new enity bean, which works. Then I add it to a OneToMany collection of another entity bean and try to merge the change. This is when I get a ConstraintViolationException.
Here is the setup:
| @Entity
| @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
| public class Person implements Serializable
| {
| @Id
| @GeneratedValue(strategy = GenerationType.IDENTITY)
| long id;
| ..
| }
|
| @Entity
| @Name("junior")
|
| public class Junior extends Person
| {
| ...
| }
|
| @Entity
| @Name("school")
|
| public class School implements Serializable
| {
| @Id
| @NotNull
| @Length(min = 5, max = 40)
| String schoolName
|
| @OneToMany(cascade = {CascadeType.ALL})
| List<Juniors> juniors = new ArrayList<Juniors>();
|
| @OneToMany(cascade = {CascadeType.ALL})
| List<Softmore> softmores = new ArrayList<Softmore>();
|
| @OneToMany(cascade = {CascadeType.ALL})
| List<Senior> seniors = new ArrayList<Senior>();
| ...
|
The following code always throws a ConstraintViolationException
| // works
| entityManager.persist(junior);
| // this causes a contraint violation
| school.getJuniors().add(junior);
| school = entityManager.merge(rewriteConfiguration);
|
The reason why this happens, is because the columns of the database table, which keeps track of the OneToMany relationships are all defined to be NOT NULL. Here comes the table:
|
| school_schoolname character varying(40)
| NOT NULL
|
| juniors_id bigint
| NOT NULL
|
| softmores_id bigint
| NOT NULL
|
| seniors_id bigint
| NOT NULL
|
|
However, all those columns SHOULD be nullable, but hibernate does not set them up like this. How can I make sure hibernate does this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083864#4083864
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083864
18 years, 9 months
[JBoss jBPM] - Re: required variables
by dleerob
I found that code in the submitParameters() method earlier, which is why I thought an exception should be thrown. However, I've just tried again, and still no exeption.
My task definition:
<start-state name="Request For New Employee">
| <task name="Request For New Employee" swimlane="Initiator">
| <controller>
| <variable name="IsReplacement" access="read,write,required"></variable>
| <variable name="EmployeeReplaced"></variable>
| <variable name="TestVariable" access="read,write,required"></variable>
| </controller>
| </task>
| <transition name="" to="Financial Director Approval 1"></transition>
| </start-state>
My action class then completes the task in the following way, but I have added a few printout lines to make sure that my IsReplacement variable is null, and they confirm that the IsReplacement variable is still null, even after calling the end method.
if (completeTask != null && completeTask.equalsIgnoreCase("Yes")) {
| try {
| log.debug("Completing Task Instance: "+taskInstance.getId());
| if (sys_transition != null && !sys_transition.equals("")) {
| taskInstance.end(sys_transition);
| }
| else {
| taskInstance.end();
| }
| messages.add(ActionMessages.GLOBAL_MESSAGE,
| new ActionMessage("task.completed"));
| }
| catch (Exception e) {
| System.out.println("####Exception when ending task!!");
| e.printStackTrace();
| }
| }
| else {
| log.debug("Saving Task Instance: "+taskInstance.getId());
| messages.add(ActionMessages.GLOBAL_MESSAGE,
| new ActionMessage("task.saved"));
| }
|
| String isReplacementVar = (String)taskInstance.getVariable("IsReplacement");
| if (isReplacementVar == null) {
| System.out.println("###isReplacementVar is NULL");
| }
| else {
| System.out.println("###isReplacementVar is NOT NULL");
| }
Please let me know if you figure out what's wrong. I will try a few more things and update this post if I find the answer.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083856#4083856
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083856
18 years, 9 months