-
1. Re: Problme in LoggedInInterceptor..
norman.richards Dec 27, 2006 11:43 AM (in response to waheed.murad)Can you show the code where you are using it?
-
2. Re: Problme in LoggedInInterceptor..
waheed.murad Dec 28, 2006 12:44 AM (in response to waheed.murad)This is my SessionBean class where i am using it what i am trying to achive is that if a user directly try to open the page by tying a URL e.g "http://localhost:8080/ereg/secretquestions.jsp" then the LoggedInIntercepter should check first that user is logged in or not if not that return to some specific page (navigation specified in the faces-config.xml )....
@Stateful
@Scope(SESSION)
@Name("SecretQuestionsAction")
@Interceptors(LoggedInInterceptor.class)
public class SecretQuestionsAction implements SecretQuestionsLocal{
@PersistenceContext(unitName="Database")
protected EntityManager em;
@In(required=false,value="SecretQuestions")
@Out(required=false,value="SecretQuestions")
private SecretQuestions secretQuestions;
@DataModel
private List allSecretQuestionsList;
@DataModelSelection(value="allSecretQuestionsList")
private SecretQuestions selectedSecretQuestion;
@In
private Context sessionContext;
@In(create=true)
FacesMessages facesMessages;
int mode=0;
String acknowledge = null;
/*--------------------------------------------------------------------*/
public String toSecretQuestionsPage(){
System.out.println("toSecretQuestionsPage method...");
return "/secretquestions.jsp";
}
public String addSecretQuestion(){
try{
if(!validateOpts()){
em.persist(secretQuestions);
secretQuestions=null;
sessionContext.remove("SecretQuestions");
getSecretQuestionsList();
acknowledge = "The Record is added successfully.";
}else{
return null;
}
}catch(Exception e){
System.out.println("Error Have accoured in\n\t SecretQuestions.java --> addSecretQuestion()? \n\t"+e.getMessage());
}
return "success";
}
/*--------------------------------------------------------------------*/
public boolean validateOpts(){
boolean isError=false;
if(secretQuestions.getSecretQuestion()==""){
facesMessages.add("secretQuestion",new FacesMessage("Please enter secret question"));
isError=true;
}
return isError;
}
/*--------------------------------------------------------------------*/
@Factory("allSecretQuestionsList")
public String getSecretQuestionsList(){
try{
setMode(0);
acknowledge = null;
allSecretQuestionsList = em.createQuery("from SecretQuestions e where e.isDeleted=0").getResultList();
}catch(Exception e){
System.out.println("Error Have accoured in\n\t SecretQuestions.java --> getSecretQuestionsList()? \n\t"+e.getMessage());
}
return null;
}
/*--------------------------------------------------------------------*/
public String deleteSecretQuestion(){
try{
SecretQuestions deleted = em.find(SecretQuestions.class, selectedSecretQuestion.getId());
if(deleted != null){
deleted.setIsDeleted(1);
}
deleted = null;
sessionContext.remove("SecretQuestions");
secretQuestions=null;
getSecretQuestionsList();
acknowledge = "The Record is deleted successfully.";
System.out.println("getting the result list complete \n\t");
}catch(Exception e){
System.out.println("Error Have accoured in\n\t SecretQuestions.java --> deleteSecretQuestion()? \n\t"+e.getMessage());
}
return null;
}
/*--------------------------------------------------------------------*/
public String updateSecretQuestion(){
try{
em.merge(secretQuestions);
setMode(0);
getSecretQuestionsList();
acknowledge = "The record is updated successfully";
}catch(org.hibernate.validator.InvalidStateException e){
System.out.println(e.getMessage());
System.out.println("error...");
InvalidValue[] val=e.getInvalidValues();
for(int i=0;i<val.length;i++){
System.out.println(val.getPropertyName());
}
}
return "successUpdate";
}
/*--------------------------------------------------------------------*/
public String showSecretQuestionDetails(){
try{
setMode(1);
acknowledge = null;
secretQuestions = em.find(SecretQuestions.class, selectedSecretQuestion.getId());
}catch(Exception e){
setMode(0);
System.out.println("Error Have accoured in\n\t SecretQuestionAction.java --> showSecretQuestionDetails()? \n\t"+e.getMessage());
}
return "/secretquestions_crud.jsp";
}
/*--------------------------------------------------------------------*/
public String loadSecretQuestion(){
System.out.println("in the getPricingOption method load");
try{
setMode(2);
acknowledge = null;
secretQuestions = em.find(SecretQuestions.class, selectedSecretQuestion.getId());
}catch(Exception e){
setMode(0);
System.out.println("Error Have accoured in\n\t SecretQuestionAction.java --> loadSecretQuestion()? \n\t"+e.getMessage());
}
return "/secretquestions_crud.jsp";
}
/*--------------------------------------------------------------------*/
public String toCreateForm(){
acknowledge = null;
resetMode();
return "/secretquestions_crud.jsp";
}
/*--------------------------------------------------------------------*/
public void resetMode(){
try{
if(secretQuestions != null){
setMode(0);
secretQuestions=null;
sessionContext.remove("SecretQuestions");
acknowledge = null;
}
}catch(Exception e){
System.out.println("Error Have accoured in\n\t SecretQuestionAction.java --> reSetMode()? \n\t"+e.getMessage());
}
}
/*--------------------------------------------------------------------*/
public int getMode() {
return mode;
}
public void setMode(int mode) {
this.mode = mode;
}
/*--------------------------------------------------------------------*/
public String getAcknowledge() {
return acknowledge;
}
public void setAcknowledge(String acknowledge) {
this.acknowledge = acknowledge;
}
/*--------------------------------------------------------------------*/
@Remove @Destroy
public void destroy(){}
/*--------------------------------------------------------------------*/
} -
3. Re: Problme in LoggedInInterceptor..
jboss.biancashouse.com Jan 4, 2007 7:23 PM (in response to waheed.murad)I use Intellij IDEA 6.0.2.
When I created a project for the seam-booking ear, I got the following warning when compiling LoggedInInterceptor.java:
Usage of java.lang.reflect.Method is not allowed in an EJB
Hope this helpful to you. -
4. Re: Problme in LoggedInInterceptor..
norman.richards Jan 4, 2007 8:15 PM (in response to waheed.murad)Which call, specifically, is failing? I notice that you aren't checking whether or not the return value is a String before returning a string. You don't want to intercept "getMode", for example.