Question

I have two actions in two different packages

<package name="default" extends="struts-default json-default" namespace="/">

      <action name="getstarted"  class="GetStartedActionBean">
            <result name="success">/jsp/getStarted.jsp</result>
            <result name="input">/jsp/getStarted.jsp</result>
      </action>
</package> 

<package name="example" extends="json-default">

      <action name="searchIndustryaction"  class="GetStartedActionBean"  method="searchIndustry">
      </action>

  </package> 

I have injected one bean it is working fine when the page loads but my search is through dwr at that time bean is not injected

in my impl

private SessionFactory sessionfactory;

 public void setSessionfactory(SessionFactory sessionfactory) {
     this.sessionfactory = sessionfactory;
}

sessionFactory is set when the execute method is called but using dwr when i called searchIndustry sessionfactory is always null

Dwr entry

<create creator="new" javascript="AdvancedSearch" scope="application">
            <param name="class" value="com.sample.dao.impl.IndustryDAOImpl"/>        
        </create>

How would I call the injected bean in dwr?

Was it helpful?

Solution

If you are using DWR means you have to put an entry like this

<create creator="spring" javascript="Industry">
<param name="beanName" value="Yourbeanname" />
</create>

but you are directly calling the class so change to this format. Hope it may useful for you

OTHER TIPS

In your dwr.xml you can make for the creator one of those :

new: Which uses the Java 'new' operator.

static: Which uses the 'getInstance()' method (by default) to obtain an instance of the class.

none: This does not create objects. See below for why. (v1.1+)

scripted: Uses a scripting language like BeanShell or Groovy via BSF.

spring: Gives access to beans through the Spring Framework.

jsf: Uses objects from JSF. (v1.1+)

struts: Uses struts FormBeans. (v1.1+)

pageflow: Gives access to a PageFlow from Beehive or Weblogic. (v1.1+)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top