JSF Spring

hello
well, i'm a new user of technologie J2EE, i am tring now to integrate both JSF and Spring in the same project. The problem is that i have a class named 'Service' declared in applicationContext.xml, and i have a managedbean witch refer to this class. The problem is that when i deploy the application FacesConfig does not recognize the class service even after i made the reference:
<application>
          <variable-resolver>
               org.springframework.web.jsf.DelegatingVariableResolver
          </variable-resolver>
          <locale-config />
</application>
the problem is persisting.
when i did the test, the sangleton Service is created, but FacesConfig still not recognize it.
Please, if any one can help me
Message was edited by:
jamasig

hello
here is my managed bean
<managed-bean>
          <description>
               Visual Bean with reference on Business Bean.
          </description>
          <managed-bean-name>userBean</managed-bean-name>
          <managed-bean-class>
               userBean.UserBean
          </managed-bean-class>
          <managed-bean-scope>request</managed-bean-scope>
          <managed-property>
               <property-name>userService</property-name>
               <value>#{userService}</value>
          </managed-property>
          <managed-property>
               <property-name>userId</property-name>
               <value>#{param.userId}</value>
          </managed-property>
     </managed-bean>
it's the 'userservice' witch it referened into ApplicationContext not recognized by Faces-Config
here is the code that declare ther 'user service' in ApplicationContext.xml
     <!-- USER Service Definition -->
     <bean id="userServiceTarget"
          class="userService.UserServiceImpl">
          <property name="userDao">
               <ref local="userDao" />
          </property>
     </bean>
     <!-- Transactional proxy for the User Service -->
     <bean id="userService"
          class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
          <property name="transactionManager">
               <ref local="transactionManager" />
          </property>
          <property name="target">
               <ref local="userServiceTarget" />
          </property>
          <property name="transactionAttributes">
               <props>
                    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                    <prop key="save*">PROPAGATION_REQUIRED</prop>
                    <prop key="update*">PROPAGATION_REQUIRED</prop>
                    <prop key="delete*">PROPAGATION_REQUIRED</prop>
               </props>
          </property>
     </bean>
thinks

Similar Messages

  • Reg. JSF Spring Integration issue.

    Hi All,
    I am using JSF for the front end and using the Spring Core, DAO and AOP for the BO and DAO layers. When i try to inject the Objects using the DI to the JSF, i am getting the following error and the objects are not getting set from the Spring.
    Error Log:*
    javax.servlet.ServletException: Unable to create managed bean dataUploadControllerBean. The following problems were found:
    - Bean or property class #{dataUploadVO} for managed bean dataUploadControllerBean cannot be found.
    - Bean or property class #{dataUploadVO} for managed bean dataUploadControllerBean cannot be found.
    - Bean or property class #{dataUploadVO} for managed bean dataUploadControllerBean cannot be found.
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
    org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:112)
    i have defined the respective entries correctly to integrate the JSF & Spring. But still the JSF&Spreing is not integrated successfully. Please find the configs defined and help to resolve the issue. i am stuck in this for 2 days...
    Web.xml
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/applicationContext.xml</param-value>
    </context-param>
    Faces-Config.xml
    <application>
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> <!-- have used this ELResolver to injects objects from Spring-->
    </application>
    <managed-bean>
    <managed-bean-name>dataUploadControllerBean</managed-bean-name>
    <managed-bean-class>com.sgspace.model.dataupload.DataUploadControllerBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>dataUploadBean</property-name>
    <value>#{dataUploadBean}</value> _<!-- Already present in the faces-config.xml-->_ </managed-property>
    <managed-property>
    <property-name>dataUploadVO</property-name>
    <property-class>#{dataUploadVO}</property-class> _<!-- Injected from Spring DI. This is currently not working.-->_
    <value></value>
    </managed-property>
    <managed-property>
    <property-name>dataUploadBO</property-name>
    <property-class>#{dataUploadBO}</property-class>_<!-- Injected from Spring DI. This is currently not working.-->_ <value></value>
    </managed-property>
    </managed-bean>
    applicationContext.xml:_
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <bean id="dataUploadDAO"
    class="com.sgspace.dao.dataupload.DataUploadDAOImpl">
    <property name="dataSource" ref="dataSource"></property>
    </bean>
    <bean id="dataUploadBO"
    class="com.sgspace.bo.dataupload.DataUploadBOImpl">
    <property name="dataUploadDAO" ref="dataUploadDAO"></property>
    </bean>
    <bean id="dataUploadVO" class="com.sgspace.vo.dataupload.DataUploadVO"></bean>
    </beans>
    Warm Regards,
    Praveen S

    The TestBean have a property for DeviceManager along with setter/getter methods as shown below. Sorry for not including in earlier posting
    TestBean.java (Backing Bean)
    private DeviceTypeManager deviceManager;
    public DeviceTypeManager getDeviceManager() {
         return deviceManager;
    public void setDeviceManager(DeviceTypeManager deviceManager) {
         this.deviceManager = deviceManager;
    Here are the two scenarios
    Scenario 1 : without <managed-property> the code works fine
    Scenario 2 : with <managed-property> the code results in following error
    javax.faces.FacesException: Cannot get value for expression '#{test.selectedDevice}'
    Scenario 1 has only JSF whereas Scenario 2 has JSF-Spring integration
    The Scenario 1 works absolutely fine as the expression '#{test.selectedDevice}' gets its value from setter/getter method in the backing bean(TestBean.java) . This is expected behaviour & wondering why it doesn't work similarly in Scenario 2 instead it complains
    Cannot get value for expression '#{test.selectedDevice}'
    I am willing to upload the war file. Any pointers/suggestions in resolving the error will be highly appreciated
    Regards
    Bansi

  • [ANN] JSF/Spring integration solution

    We developed a solution for integrating JSF with the Spring framework (http://www.springframework.org/), a well-designed, extensible and easy-to-use Java framework built around an Inversion of Control container (see http://martinfowler.com/articles/injection.html).
    Our glue code wraps the JSF context into a Spring context and thus merges them. This way, the JSF context becomes part of Spring and vice versa. This is done in a implementation independent way so that it can be used with any JSF implementation.
    For source code, documentation and an example application see http://sourceforge.net/projects/jsf-spring.
    Any comments are greatly appreciated!

    I'm experiencing problem in using the
    jsf-spring-2.4-example sample application. The
    following errors was returned:
    ============================================
    javax.servlet.ServletException:
    javax.servlet.jsp.JspException:
    org.springframework.beans.factory.BeanDefinitionStoreException:
    IOException parsing XML document from resource
    [WEB-INF/faces-config.xml] of ServletContext; nested
    exception is java.net.UnknownHostException:
    java.sun.com
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.showNames_jsp._jspService(showNames_jsp.java:91)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    org.springframework.web.jsf.RequestHandledFilter.doFilter(RequestHandledFilter.java:116)
    ============================================
    As far as I understand, the error was caused by some
    class within the sample application which tries to
    connect to the Internet. When I'm currently connected
    to the Internet which I cannot always do because I'm
    using a prepaid connection, the error suddenly
    disappear. This makes testing of the application
    difficult when constant Internet connection is absent.
    I hope you can shed light to me regarding this matter.
    Thank you very much!

  • JSF & Spring integration

    Hi there,
    i want to integrate spring with my existing application. is there any good tutorials in net to give good view on that. i google it but not fully satisfied.
    please help me if you have any idea..
    Regards,
    A.

    The TestBean have a property for DeviceManager along with setter/getter methods as shown below. Sorry for not including in earlier posting
    TestBean.java (Backing Bean)
    private DeviceTypeManager deviceManager;
    public DeviceTypeManager getDeviceManager() {
         return deviceManager;
    public void setDeviceManager(DeviceTypeManager deviceManager) {
         this.deviceManager = deviceManager;
    Here are the two scenarios
    Scenario 1 : without <managed-property> the code works fine
    Scenario 2 : with <managed-property> the code results in following error
    javax.faces.FacesException: Cannot get value for expression '#{test.selectedDevice}'
    Scenario 1 has only JSF whereas Scenario 2 has JSF-Spring integration
    The Scenario 1 works absolutely fine as the expression '#{test.selectedDevice}' gets its value from setter/getter method in the backing bean(TestBean.java) . This is expected behaviour & wondering why it doesn't work similarly in Scenario 2 instead it complains
    Cannot get value for expression '#{test.selectedDevice}'
    I am willing to upload the war file. Any pointers/suggestions in resolving the error will be highly appreciated
    Regards
    Bansi

  • JSF/Spring integration - managed-property problem

    I am using JSF 1.1_01 (MyFaces 1.1), Spring 1.2, Ajax4Jsf.
    The JSF application has h:selectOneMenu .
    On change event of h:selectOneMenu sets "selectedValue" into backing bean as shown below:
    page.jsp
    <h:selectOneMenu value="#{test.selectedDevice}" >
    <f:selectItem itemValue="0" itemLabel="--New--"/>
    <f:selectItem itemValue="1" itemLabel="WorkStation"/>
    <f:selectItem itemValue="2" itemLabel="Router"/>
    <f:selectItem itemValue="3" itemLabel="Switch"/>
    <ajax:support action="#{test.loadDevice}" event="onchange" reRender="t2,t3,t4,t5"/>
    </h:selectOneMenu>
    TestBean.java (Backing Bean)
    public String getSelectedDevice() {
    logger.info(" *** In getSelectedDevice *** ");
    if (selectedDevice == null) {
    selectedDevice = "0"; // This will be the default selected item.
    return selectedDevice;
    public void setSelectedDevice(String selectedDevice) {
    logger.info(" *** In setSelectedDevice *** ");
    this.selectedDevice = selectedDevice;
    Here are the configuration file snippets for integrating JSF Spring
    web.xml
    <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    faces-config.xml
    <application>
    <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
    </application>
    <managed-bean>
    <managed-bean-name>test</managed-bean-name>
    <managed-bean-class>test.TestBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>deviceManager</property-name>
    <property-class> test.DeviceTypeManager </property-class>
    <value>#{deviceManager}</value>
    </managed-property>
    </managed-bean>
    The above code results in the following error
    javax.faces.FacesException: Cannot get value for expression '#{test.selectedDevice}'
    The error occurs only if i include <managed-property> inside the <managed-bean> in faces-config.xml.
    The moment i remove <managed-property> from face-config.xml the error disappears & page gets rendered properly.
    The purpose in having <managed-property> inside managed-bean is to call Spring's Manager class (i.e. deviceManager) from JSF application
    Any pointers/suggestions in resolving the error will be highly appreciated
    Regards
    Bansi

    The TestBean have a property for DeviceManager along with setter/getter methods as shown below. Sorry for not including in earlier posting
    TestBean.java (Backing Bean)
    private DeviceTypeManager deviceManager;
    public DeviceTypeManager getDeviceManager() {
         return deviceManager;
    public void setDeviceManager(DeviceTypeManager deviceManager) {
         this.deviceManager = deviceManager;
    Here are the two scenarios
    Scenario 1 : without <managed-property> the code works fine
    Scenario 2 : with <managed-property> the code results in following error
    javax.faces.FacesException: Cannot get value for expression '#{test.selectedDevice}'
    Scenario 1 has only JSF whereas Scenario 2 has JSF-Spring integration
    The Scenario 1 works absolutely fine as the expression '#{test.selectedDevice}' gets its value from setter/getter method in the backing bean(TestBean.java) . This is expected behaviour & wondering why it doesn't work similarly in Scenario 2 instead it complains
    Cannot get value for expression '#{test.selectedDevice}'
    I am willing to upload the war file. Any pointers/suggestions in resolving the error will be highly appreciated
    Regards
    Bansi

  • JSF, Springs and Hibernate

    Hi,
    I am a newbie. I would like to know the books i need to refer to, inorder to learn JSF, springs and hibernate.
    Thank you,

    The_Matrix wrote:
    CeciNEstPasUnProgrammeur wrote:
    How about learning Java first?
    At least for JSPs, there are free online tutorials from Sun. There are likely to be similar resources for Spring and Hibernate.I Know Java. I am a Sun Certified Java Programmer. I also know know J2EE. I am trying to learn the new technologies. Therefore i mentioned that i am a newbie, it was pertianing to JSF, Springs and Hibernate. Not to Java.In that case:
    Core Java Server Faces (2nd edition)
    Java Persistence with Hibernate
    Pro Spring 2.5
    Expert Spring MVC and Web Flow
    Together with the product documentation those should make a decent bit of reading.

  • Training material on JSF, Spring and Hibernate

    Hi All,
    I'm new to JSF. I need some good training material on JSF, Spring and Hibernate.
    I've tried lot many tutorials online, but cannot find a real good one.
    Also I need to learn how we can integrate together JSF, Spring and Hibernate to build web applications.
    Thanks
    Payal

    As far as documentation vs examples, that depends on the individual.
    The Spring documentation is quite large, but Spring itself is very modular. So you can pretty much get away with reading the pieces you need when you need them and ignoring the rest.
    Start with inversion of control until you feel you understand the concept. At its core, the idea is simple. Suppose you have a business class, FooService, and it needs to utilize BarService to implement its business logic. The non-Spring way would be to have the FooService class be responsible for getting an instance of BarService. The Spring way is for FooService to have a setter to be given an instance of BarService:
    public class FooServiceImpl implements FooService
        private BarService barService;
        public void setBarService(BarService barService) { this.barService = barService; }
    }Then the Spring container is used to "wire together" the instances:
    <beans>
        <bean id="barService" class="BarServiceImpl" />
        <bean id="fooService" class="FooServiceImpl">
            <property name="barService" ref="barService" />
        </bean>
    </beans>Note the advantage when using the classes in different contexts, e.g. unit testing vs production.
    If I were you, I would take the sample app you have already done with JSF and try to integrate Spring into it. Move all the business logic into beans in the Spring container while keeping the view logic in the JSF layer.

  • Transfer Object in JSF, Spring, and Hibernate

    The application on which I am working deploys the JavaServer Faces, Spring and Hibernate frameworks.
    We are going to use the "transfer object" to move data between J2EE tiers from the front end to the back end and vice versa. In addition, data "types" may need to be converted --
    At the front end, the "type" of the data that are entered by users may not match that in the database table. For example, checkboxes may be marked or left blank by users. The "type" of the checkboxes is "boolean" in the JSF backing bean. However, we have either "Y" or "N" for the corresponding field in the database table.
    The JSF backing bean holds data as well as controller functionality. Of course, the transfer object holds data only.
    With regard to class properties, Is the transfer object an exact copy of the JSF backing bean? And at which tier the data are converted to match their correspoding "types" in the database tables?
    We also have the "data objects" which are exact representation of database tables.
    Thanks for your advices.

    Small example: you can decide in the business layer
    whether to convert it to boolean or Boolean (which
    has a 3rd state: null).But it all goes back to your data model. If your data model supports null for that property, then of course boolean is a poor choice. If that case one could use Boolean. None of this has anything to do with re-usability, which was your objection.
    I think the re-usability question goes back to the data model as well. Suppose your data model says this property is boolean valued. However if your database does not support booleans natively, then you need to map the value for storage in the database. But that is the data persistence layers problem.
    OTOH, suppose your data model says that this property may be 'Y' or 'N'. Then the Java class represent the business object should not have a boolean property, we should make it match the data model.
    However, I think that most cases where people are storing 'Y' or 'N' in a field in the database fall into the first case, where the data model is a boolean and they are working around limitations in the database. There is no reason in that case to perpetuate the same limitations in the Java code.

  • Getting error in simple Jsf-Spring Integration

    Hi,
    I am getting error in setting class attribute through Spring when I am integrating spring1.2 and jsf 1.1. Alone JSF is working fine.
    The error I am getting is
    Class org.springframework.web.jsf.DelegatingVariableResolver is no javax.faces.el.VariableResolverI m using JSF1.1, Spring 1.2 and jdk 1.4
    How I did is I added a class First.java initialized by application.xml as follows
    <beans>
         <bean id="first" class="com.tst.beans.First" >
         <property name="name">
              <value type="java.lang.String">abc</value>
         </property></bean>
    </beans>I have added Delegating Variable resolver and other stuff in faces-config.xml as follows
        <application>
    <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
          <locale-config>
            <default-locale>en</default-locale>
          </locale-config>
          <message-bundle>com.Messages</message-bundle>
        </application>
         <navigation-rule>
              <from-view-id>/third.jsp</from-view-id>
         </navigation-rule>
         <managed-bean>
              <managed-bean-name>secBean</managed-bean-name>
            <managed-bean-class>com.tst.beans.SecBean</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
              <managed-property>
                   <property-name>ft</property-name>
                   <value>#{first}</value>
              </managed-property>
         </managed-bean>In web.xml I did the following change for Spring
      <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
      </context-param>
          <!--Loads Spring application context upon application startup.-->
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
           <servlet>
                 <servlet-name>SpringContextServlet</servlet-name>
                    <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>      
                <load-on-startup>1</load-on-startup>
         </servlet>
      I added this first class in backing bean as a property. My faces-config.xml code is
              <managed-bean>
              <managed-bean-name>EducInfo</managed-bean-name>
              <managed-bean-class>
                   com.view.beans.StudentEducInfo
              </managed-bean-class>
                    <managed-property>
                   <property-name>ft</property-name>
                   <value>#{first}</value>
              </managed-property>and in JSP page, I called the managed property as
    <h:outputText value="#{secBean.ft.name}" ></h:outputText>Any pointers? Any workaround would also be highly appreciated
    Regards,
    Arsalan

    There is a working apache example in the SVN...might be worth taking a look at that.

  • Getting a problem in JSF - Spring Integration

    Hi,
    We have a web application in which we are working on JSF using MyEclipse. I am now trying to integrate spring framework into the project for having IOC for middle layer.
    well I am getting problem in setting class attribute through Spring.
    How I did is I added a class First.java initialized by application.xml The code is
    <beans>
         <bean id="first" class="com.model.service.impl.first"
              abstract="false" singleton="false" >
         <property name="name">
              <value type="java.lang.String">to enter</value>
         </property></bean>
    </beans>In web.xml I did the following change for Spring
         <servlet>
                 <servlet-name>SpringContextServlet</servlet-name>
                 <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>      
                <load-on-startup>1</load-on-startup>
         </servlet>I added this first class in backing bean as a property. My faces-config.xml code is
              <managed-bean>
              <managed-bean-name>EducInfo</managed-bean-name>
              <managed-bean-class>
                   com.view.beans.StudentEducInfo
              </managed-bean-class>
                    <managed-property>
                   <property-name>ft</property-name>
                   <value>#{first}</value>
              </managed-property>and I called it from jsp(JSF) page as
    <h:outputText value="#{EducInfo.tstFirst}" />the function tstFirst in EducInfo (backing bean) is
         private first ft;
         public String getTstFirst() {
              tstFirst=ft.getName();
              return tstFirst;
    I am getting error 'Expression Error: Named Object: 'first' not found.'
    Any idea? Any workaround would also be appreciated.
    Thanks,
    Arsalan

    Your server is not able to find anything matching the requested file.
    Well, just explore your archive file (possibly your .war file) and look at the path of the index file.
    Please post your url. If pro11 is your project name (the root) then ensure that the index file is by itself ie the path should be shown as blank in your war file.
    Or mention the exact path of your index file in the url.

  • How to design a framework for implementing rules in JSF/Spring Application

    We use JSF 1.2 (MyFaces 1.2.2) in the presentation layer, Spring 2.5.3 in the service layer and Hibernate3.2 as persistence layer.
    The java application we are building is mostly CRUD but involves tons of business rules which needs to be implemented at both presentation and service layers
    We are planning to design a business rule framework so that developers can work on individual business rules without stepping on each other and also to prevent redundant implementation of the same business rules .
    Here are the Goals
    Solution Goals:
    &bull; Business rules are implemented in only one piece of code. i.e. Rule is packaged into a unit
    &bull; Business rules have an consistent, identifiable form.
    &bull; Rules have to be Abstract
    &bull; View technology like JSF says I want to createManufacturer(Manufacturer manuf) passing Manufacturer object as parameter. Then the business rule framework should go and fetch the rules to do the job of createManufacturer () and then return the result.
    &bull; Fetch the Rule based on
    �X Target object
    Is the concrete object on which you are performing the Rule for example Device object
    �X Operation Type
    Is C R U D Validate
    Proposed Solution:
    &bull; To have catalog of business rules which will have name of the rulewith parameters and dependencies
    &bull; To have Rule Context designed in such a way that it goes and fetches the Rule i.e. give me all the Rules from the RuleContext and the client will decide which Rule to Apply.
    We modeled the business rule framework as a variant of Strategy pattern. But this approach has limitation in the sense it requires Rules to be injected into the Service Layer Spring Beans .
    Then we looked at other design patterns like Command, Visitor but that doesn&rsquo;t seems to fit the bill either.
    Any pointers/suggestions will be greatly appreciated

    "In many cases multiple instances of a single class works just as well."
    This sounds a lot like the way I would do something in other languages. I would simply create an array of structs (or records) containing variables like these:
    type critter:record
      int x,y; // The critter's position, of course
      int vx,vy; // Used to keep track of velocity
      int ctype; // What kind of thing this is
      int subtype; // Additional flags or info that may affect behavior
      int yadayadayada,etcetera;
    end;
    var critters:array[0..somelargenumber] of critter;Of course, I suspect that what may work well in Pascal might not work as well in Java. For one thing, I don't think Java even has records per se. It may be necessary to use a class to duplicate that functionality. (Is this true? Or did I miss something?) The array then becomes an array of objects.
    Since I'm using classes anyway, I guess it makes sense that I should go all the way, creating interfaces for common functions and subclassing a basic Critter class for each different kind of critter (at least in cases where the behavior and/or rendering methods would be significantly different from the basic class methods).
    This is okay as long as I don't go overboard, right?

  • Help me out with Directory structure for JSF+SPRING+HIBERNATE Project

    Hi frnds ,
    My name is Walter working for a startup software company . We are working on Hospital Management System (HMS) project .. MVC Architecture ...using Hibernate Spring and JSF ..we need to design Directory Structure for our project..
    plzz help me friends in suggesting MVC Directory structure ...? also plzz help me by directing me with the navigation flow?
    Thnxx in advance
    Regards
    Walter

    Thank you so much .. friends ..for your kind replies..thanks to Illu, anguquga and special thanks to BalusC for giving me the advice for hiring EE Artitech ..
    Anyways I have discussed with my teammates designing the directory structure
    anguquga your directory structure is close to what I have designed ..referiing to a sample application on web..
    Hospital Management system MVC architecture Directory structure
    This is the way the structure goes on ..
    model --> for Hibernate as well as Spring
    View --> for JSF
    src(-)
    |
    ------(-) java
         |
         -------(-) model
              |
              ------(+) businessobject
              |
              ------(-) dao
              |
              ------(+) hibernate
              |
              ------(+) exception
              |
              ------(-) service
              |
              ------ (+) impl
              |
              ------(+) util
              (-) view
              |
              ------(+) bean
              |
              ------(+) builder
              |
              ------(+) bundle
              |
              ------(+) servicelocator
              |
              ------(+) util
              |
              ------(+) validator
    (-) Web or WebRoot
    |
    ----- (-) JSP Files�etc.,
    |
    ----- (-) META-INF
    |
         ------     (+) Images
    |
         ------     (+) Scripts ==== CSS (cascading style sheets, JavaScript files etc.,)
    |
    ----- (-) WEB-INF =========xml files web.xml, faces-config.xml etc.,
         |
         -----(-) Classes
              |
    -----(-) HMS
    |
                   ----- (+) model
                   |
                   ----- (+) view
    |
    ----- (+) lib
    I am sure you may notice few errors .. if u find any plzz reply me back.... thnxx in advance for replies...and thnxx for giving your valuable replies...
    Walter (Kaleem)

  • Jsf spring hibernate session

    Hi, I'm currently using hibernate spring and JSF  1/ the first problem In the JSF common header page I try to test if a bean is in the session scope in order to show login or logout link, and the test always fails : the logout link is always displayed.  the JSF page : [code] <f:subview id="header" >        <h:form id="headerForm"> <table cellspacing="0" width="100%"> <tr> <td align="left" valign="middle">           <img border="0" src="images/logo1.jpg"/> </td>  <td align="right" valign="middle"> <br> <!--Accueil< -->  <c:choose> <c:when test="${empty sessionScope.accountBean}">  <h:commandLink action="Sign on"> <h:outputText value="Sign on"/> </h:commandLink>  </c:when> <c:otherwise> <h:commandLink id ="logout" action="#{accountBean.logoutAction}" >      <h:outputText value="log out"/> </h:commandLink> </c:otherwise> </c:choose> </td> </tr> </table>  <table cellspacing="0" width="100%"> <tr> <td> <hr color="#99ca3c" size="5" noShade SIZE=1> </td> </tr> </table>       </h:form> </f:subview>   [/code]   The accountBean code : [code] public class AccountBean extends BaseBean{ //private Logger log = Log.getLog(this); private String uid; private String password;  private boolean loggedIn; private AdminService adminService; private Admin admin; public AccountBean() { this.logger.debug("Authentication"); this.loggedIn = false; uid=null; password=null; // admin=new Admin(); } public String loginAction() {           try { this.logger.debug("loginAction");  admin = adminService.login(this.uid, this.password); //this.serviceLocator.getUserService().login(this.username, this.password);                                if (admin != null) { if("".equals(admin.getUid())|| "".equals(admin.getPassword())){ this.loggedIn=false; String msg = "Le mot de passe et l'identifiant doivent etre saisis ";                     addErrorMessage(msg + ", saississez un mot de passe et un identifiant corrects"); return NavigationResults.RETRY; } else{                     this.loggedIn = true; HttpSession session = SessionUtil.getSession(); session.setAttribute("Admin", this.uid);                                          return NavigationResults.SUCCESS; }                }                else {                     this.loggedIn = false;                                          String msg = "Le mot de passe est incorrect ";                     addErrorMessage(msg + ", saississez un mot de passe correct");                     this.logger.debug(msg);                                          return NavigationResults.RETRY;                }           }           catch (UsernameNotExistException ue) {                String msg = "L'identifiant (login) est incorrect";                this.logger.info(msg);                addErrorMessage(msg + ", ressaysissez votre identifiant.");                                return NavigationResults.RETRY;           }           catch (Exception e) {                this.logger.error("Could not log in user.", e);                addInfoMessage("Could not log in user: Internal Error");                                return NavigationResults.FAILURE;           }      }            /**      * The backing bean action to logout a user.      *       * @return the navigation result      */      public String logoutAction() {           //this.clear(); FacesContext fc = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) fc.getExternalContext().getSession(false); session.invalidate();            this.logger.debug("Logout successfully.");                      return NavigationResults.MAIN;      }        public String getPassword() { return password; }  public void setPassword(String password) { this.password = password; }  public String getUid() { return uid; }  public void setUid(String uid) { this.uid = uid; }  public Admin getAdmin() { return admin; }   public boolean getLoggedIn() { return loggedIn; }  public void setLoggedIn(boolean loggedIn) { this.loggedIn = loggedIn; }  public void setAdminService(AdminService adminService) { this.adminService = adminService; }   }    [/code]  the faces managed bean configuration [code] <managed-bean-name>accountBean</managed-bean-name> <managed-bean-class>fr.cbmjadmin.views.bean.AccountBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property>      <property-name>adminService</property-name> <value>#{adminService}</value> </managed-property>    [/code] 2/ the second problem : my application shows a list of datas. I log on the application , i update this list outside the application ( by using sql command) , i try to list my data using the application : the application does not reflect the modifications. I logout using the log out link, then i log on and the application does not reflect the modifications.  what happens? How could I resove these problems. How can i logout properly? how can i show logout link when the user is logged in? and hide the log out link when the user is logout Thanks.

    For the first problem, you need to realize that the accountBean always exists since you configured it in the faces-config.xml. So you should use something else (like a property on the bean) to determine if the user has actually logged in.
    Secondly, but still on the first issue, it is preferable to use the rendered attribute on the standard JSF components in this situation, instead of the JSTL tags.
    Now, as to the second problem, there are a number of possibilities:
    - did you commit the changes to the database?
    - did you verify that another connection with the native db client can see the changes?
    - are you using a cache with Hibernate? Are you taking the proper steps to notify the cache it might have stale data?
    - are you keeping the list in session scope in your application? (Logging out doesn't clear the session unless you explicitly code it that way.)

  • JSF - spring - hibernate and session

    Hi,
    I'm currently using hibernate spring and JSF
    1/ the first problem
    In the JSF common header page I try to test if a bean is in the session scope in order to show login or logout link, and the test always fails : the logout link is always displayed.
    the JSF page :
    <f:subview id="header" >
        <h:form id="headerForm">
            <table cellspacing="0" width="100%">
        <tr>
            <td align="left" valign="middle">
                  <a href="front.jsf"><img border="0" src="images/logo1.jpg"/></a>
            </td>
        <td align="right" valign="middle"> <br>
       <!--<a href="front.jsf" rendered="#"> Accueil<</a> -->
        <c:choose>
                    <c:when test="${empty sessionScope.accountBean}">
                        <h:commandLink action="Sign on">
                            <h:outputText value="Sign on"/>
                        </h:commandLink>  
                    </c:when>
                    <c:otherwise>
                        <h:commandLink id ="logout" action="#{accountBean.logoutAction}" >
                             <h:outputText value="log out"/>
                        </h:commandLink>
                   </c:otherwise>
                </c:choose>
            </td>
        </tr>
    </table>
    <table cellspacing="0" width="100%">
        <tr>
            <td>
                <hr color="#99ca3c"  size="5" noShade SIZE=1>
            </td>
        </tr>
    </table>
         </h:form>
    </f:subview>The accountBean code :
    public class AccountBean extends BaseBean{
    //private Logger log = Log.getLog(this);
        private String uid;
        private String password;
        private boolean loggedIn;
        private AdminService adminService;
        private Admin admin;
        public AccountBean() {
            this.logger.debug("Authentication");
            this.loggedIn = false;
            uid=null;
            password=null;
           // admin=new Admin();
    public String loginAction() {
              try {
                        this.logger.debug("loginAction");
                         admin = adminService.login(this.uid, this.password);
                                    //this.serviceLocator.getUserService().login(this.username, this.password);
                   if (admin != null) {
                                if("".equals(admin.getUid())|| "".equals(admin.getPassword())){
                                 this.loggedIn=false;
                                    String msg = "Le mot de passe et l'identifiant doivent etre saisis ";
                        addErrorMessage(msg + ", saississez un mot de passe et un identifiant corrects");
                                 return NavigationResults.RETRY;
                                else{
                        this.loggedIn = true;
                                    HttpSession session = SessionUtil.getSession();
                                    session.setAttribute("Admin", this.uid);
                        return NavigationResults.SUCCESS;
                   else {
                        this.loggedIn = false;
                        String msg = "Le mot de passe est incorrect ";
                        addErrorMessage(msg + ", saississez un mot de passe correct");
                        this.logger.debug(msg);
                        return NavigationResults.RETRY;
              catch (UsernameNotExistException ue) {
                   String msg = "L'identifiant (login) est incorrect";
                   this.logger.info(msg);
                   addErrorMessage(msg + ", ressaysissez votre identifiant.");
                   return NavigationResults.RETRY;
              catch (Exception e) {
                   this.logger.error("Could not log in user.", e);
                   addInfoMessage("Could not log in user: Internal Error");
                   return NavigationResults.FAILURE;
          * The backing bean action to logout a user.
          * @return the navigation result
         public String logoutAction() {
              //this.clear();
               FacesContext fc = FacesContext.getCurrentInstance();
               HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);
               session.invalidate();
              this.logger.debug("Logout successfully.");
              return NavigationResults.MAIN;
        public String getPassword() {
            return password;
        public void setPassword(String password) {
            this.password = password;
        public String getUid() {
            return uid;
        public void setUid(String uid) {
            this.uid = uid;
        public Admin getAdmin() {
            return admin;
        public boolean getLoggedIn() {
            return loggedIn;
        public void setLoggedIn(boolean loggedIn) {
            this.loggedIn = loggedIn;
        public void setAdminService(AdminService adminService) {
            this.adminService = adminService;
    }the faces managed bean configuration
    <managed-bean-name>accountBean</managed-bean-name>
        <managed-bean-class>fr.cbmjadmin.views.bean.AccountBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
         <property-name>adminService</property-name>
                <value>#{adminService}</value>
        </managed-property>2/ the second problem :
    my application shows a list of datas.
    I log on the application , i update this list outside the application ( by using sql command) , i try to list my data using the application : the application does not reflect the modifications. I logout using the log out link, then i log on and the application does not reflect the modifications.
    what happens?
    How could I resove these problems.
    How can i logout properly?
    how can i show logout link when the user is logged in? and hide the log out link when the user is logout
    Thanks.

    It depends on how you want to reprecate the session btwn instances or cluters
    there are three kinds File System, Memory to Memory, HA
    You can configure it from this property in the admin console
    Configuration on a cluster -> Availability Service -> Web Container Availability -> Persistence Type:

  • JSF + Spring / AOP

    Hi,
    I have a problem when I try to run a web application where I use JSF with Springs AOP
    Here's my spring.xml:
    <beans>
    <!-- Bean Classes -->
    <bean id="beanTarget" class="BusinessLogic" />
    <!-- Advice classes -->
    <bean id="theTracingBeforeAdvice" class="TracingBeforeAdvice" />
    <!-- Bean Config -->
    <bean id="businesslogicbean" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="proxyInterfaces">
    <value>IBusinessLogic</value>
    </property>
    <property name="target">
    <ref local="beanTarget" />
    </property>
    <property name="interceptorNames">
    <list>
    <value>theTracingBeforeAdvisor</value>
    </list>
    </property>
    </bean>
    <!-- Advisor pointcut defintion for before advice -->
    <bean id="theTracingBeforeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor" >
    <property name="advice">
    <ref local="theTracingBeforeAdvice" />
    </property>
    <property name="pattern">
    <value>.*</value>
    </property>
    </bean>
    </beans>Theres a function in the businessLogik-class which is invoked when the user presses a commandButton in the faces file.
    <h:commandButton action="#{beanTarget.foo}"/>In the foo function a System.out.println is invoked.
    The TracingBeforeAdvice implements the interface org.springframework.aop.MEthodBeforeAdvice which contains the method before(...). Here's also a System.out.println invokation.
    My problem is that the foo method is invoked but not the before method...
    I got the example from http://www.onjava.com/pub/a/onjava/2004/07/14/springaop.html (I left out the AfterReturnAdvice)
    Does anybody has an idea on this...?
    Thanks in advance

    Hello,
    Could you be more specific about the version of OC4J you are using, and also what is the fail-over you are talking about? Do you have any stack trace ?
    Regards
    Tugdual Grall

Maybe you are looking for

  • Questions on Mackeeper and clearing out junk! Help!

    I downloaded Mackeeper and it told me junk was slowing down my Mac but after it asked for $88 i quickly uninstalled it. Im worried it left a virus that slowed down my Macbook Pro. Even tho everyone says Macs don't need antivirus ware, is there someth

  • Sales order for a configurable material

    Hi all, While creating a sales order for a configurable material i'm encountering an incompletion log saying enter gross weight & net weight. Even after i enter some value in the respective fields, i'm still thrown with the same incompletion & i'm un

  • Support of multiple transports by OWSM

    Hi, i have IBM WBI (Message broker) as hub and spoke for the web services and I am going to use OWSM as soa governance tool with novell Access manager as LDAP server. I am wondering whether there is any success story with this kind of configuration.

  • Prevent pdfmaker.xla being installed

    We use MS Office 2003.  When Adobe Reader is installed an Excel add-in called pdfmaker.xla is installed into the XLSTART folder which then causes an error message to appear when Excel is started, "Compile error in hidden module: AutoExecNew", and the

  • No audio when importing footage under capture

    When I'm importing footage from my camcorder into FCE there is audio in the caputure window & no levels on my audio meters. The camcorder I'm using is a ZR500 Mini DV using to import. These are the steps I have done: File -> Easy Setup then Format: -