[JBoss Seam] - Re: Problme in LoggedInInterceptor..
by 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(){}
/*--------------------------------------------------------------------*/
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996576#3996576
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996576
18 years, 10 months
[Installation, Configuration & Deployment] - failed to run apps after jboss deployment
by amitkanjilal
Hi All,
I have deployed my application inside jboss.let me give my folder structure for deployment,its as follows:
<jboss-home>/my_own_instance/deploy/fxtxnbean/fc@4/src /classes/nb.war(exploded one),fxtxn.jar
in the above context: src contains my source code & classes contains all class file.whenever i am deploying,after starting the server,i specify the file path in the deploy(string) of jmx-console-->MainDeployer& i invoke,both the war(exploded) & jar gets deployed.and i load my external properties through jmxconsole-->systemproperties.properties get loaded.now whenever i am running my apps using(http://myhost:8080/nb(exploded)/rl.html and specify my uid and pwd...this is showing following error:
11:04:58,147 INFO [SystemPropertiesService] Loaded system properties from: file:/D:/jboss-4.0.4/server/MOB_SERVER/deploy/FCATTxnBean/fc@4.2
11:05:38,653 ERROR [STDERR] java.lang.Exception: [JFProperties], Undefined System Property 'fcat.jvm.id'
11:05:38,653 ERROR [STDERR] at com.iflex.fcat.infra.JFProperties.loadProperties(JFProperties.java:284)
11:05:38,653 ERROR [STDERR] at com.iflex.fcat.servlet.EntryBase.doStaticInit(EntryBase.java:325)
11:05:38,653 ERROR [STDERR] at com.iflex.fcat.servlet.EntryBase.(EntryBase.java:303)
11:05:38,653 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
11:05:38,653 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
11:05:38,653 ERROR [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
11:05:38,653 ERROR [STDERR] at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
11:05:38,653 ERROR [STDERR] at java.lang.Class.newInstance0(Class.java:308)
11:05:38,653 ERROR [STDERR] at java.lang.Class.newInstance(Class.java:261)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1055)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
11:05:38,653 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
11:05:38,653 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
11:05:38,653 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
11:05:38,653 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
11:05:38,653 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.
11:05:38,653 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
11:05:38,653 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
11:05:38,653 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)
11:05:38,653 ERROR [[RetailServlet]] Allocate exception for servlet RetailServlet
javax.servlet.ServletException: Servlet initialization has failed
at com.iflex.fcat.servlet.EntryBase.init(EntryBase.java:631)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:534)
the class file for the Servlet(entery servlet) it is giving error for is there inside src/classes/servlet/entryservlet.class
Plz,help me out from this....i am running out of time...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996575#3996575
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996575
18 years, 10 months
[JBoss Seam] - Re: Showing updated entity on postback
by nbhatia
Correct - the child is added fine, but the rendered page does not show the newly added child. The reason is that the Thread and Posts are fetched from the database during the Apply Request Values phase, and only later in the Invoke Application phase the new Post is inserted.
Here's the source for the rendered page - Thread.xhtml:
| <body>
| <ui:composition template="/layout/template.xhtml">
|
| <ui:define name="body">
|
| <div id="PageSubtitle">Thread</div>
|
| <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
|
| <div id="List">
| <h2>#{threadHome.instance.title}</h2>
|
| <h:outputText value="No posts" rendered="#{empty threadHome.posts}"/>
|
| <div class="Post">
| <ui:repeat value="#{threadHome.posts}" var="post" rendered="#{not empty threadHome.posts}">
| <div class="Body">#{post.body}</div>
| </ui:repeat>
| </div>
| </div>
|
| <h:form>
| <div class="NewPost">
| <div class="Post" >
| <div class="Body">
| <h:inputTextarea id="body"
| rows="4"
| cols="20"
| required="true"
| value="#{postHome.instance.body}"/>
| </div>
| </div>
| </div>
|
| <div class="Info">
| <h:commandButton id="save"
| value="Post Reply"
| action="#{postHome.persist}"
| styleClass="Button" />
| </div>
| </h:form>
|
|
| </ui:define>
|
| </ui:composition>
| </body>
|
This is ThreadHome:
| @Name("threadHome")
| public class ThreadHome extends EntityHome<Thread> {
|
| @In(value = "#{forumHome.instance}", required = false)
| Forum forum;
|
| public void setThreadId(Long id) {
| setId(id);
| }
|
| public Long getThreadId() {
| return (Long) getId();
| }
|
| @Override
| protected Thread createInstance() {
| Thread result = new Thread();
| result.setForum(forum);
| return result;
| }
|
| public List<Post> getPosts() {
| return getInstance() == null ? null : new ArrayList<Post>(getInstance()
| .getPosts());
| }
|
| }
|
and finally here's PostHome, which contains the persist action which is called from Thread.xhtml.
| @Name("postHome")
| public class PostHome extends EntityHome<Post> {
|
| @In(value = "#{threadHome.instance}", required = false)
| Thread thread;
|
| public void setPostId(Long id) {
| setId(id);
| }
|
| public Long getPostId() {
| return (Long) getId();
| }
|
| @Override
| protected Post createInstance() {
| Post result = new Post();
| result.setThread(thread);
| return result;
| }
|
| @Override
| public String persist() {
| if (this.instance.getDateCreated() == null) {
| this.instance.setDateCreated(new java.util.Date());
| }
| return super.persist();
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996574#3996574
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996574
18 years, 10 months