Results 1 to 4 of 4

Thread: possible?<set name="viewScope.myModelClass" value="myModelClass" type="xyz.MyModel.."

  1. #1
    Join Date
    Oct 2008
    Posts
    286

    Default [SOLVED]possible?<set name="viewScope.myModelClass" value="myModelClass" type="xyz...

    it is possible to create a new instance every time you enter the view-state via set tag?

    Code:
    	<view-state id="enterModelForm" view="view-modelForm" model="modelClass" >
    		<on-entry>
    			<set name="viewScope.modelClass" value="modelClass" type="xyz.ModelClass"></set>
    		</on-entry>
    	</view-state>
    my goal is to create a new instance upon view-state starts.
    or any better approach is highly appreciated.

    thanks
    Last edited by eros; Apr 24th, 2010 at 12:57 AM. Reason: tag as SOLVED
    Eros

    Environment:
    JSP 2.0
    Dojo 1.4.1
    Ext JS 3.1 (testing)
    Spring MVC 2.5.6.SEC01 (planning to Spring 3 using STS)
    STS
    SWF 2.0.9.RELEASE
    Tiles 2.0.5
    iBatis: ibatis-sqlmap-2.3.4.726

  2. #2
    Join Date
    Oct 2008
    Posts
    286

    Default

    i found the solution by trial and error..

    Code:
    		<on-entry>
    			<evaluate expression="new xyz.ModelClass()"
    				result="viewScope.modelClass"></evaluate>
    		</on-entry>
    Eros

    Environment:
    JSP 2.0
    Dojo 1.4.1
    Ext JS 3.1 (testing)
    Spring MVC 2.5.6.SEC01 (planning to Spring 3 using STS)
    STS
    SWF 2.0.9.RELEASE
    Tiles 2.0.5
    iBatis: ibatis-sqlmap-2.3.4.726

  3. #3
    Join Date
    Nov 2008
    Posts
    742

    Default

    Wow...using new works like that in an evaluate action? Didn't realize that. My solution is typically to define a prototype-scoped bean (with ID such as newModelClass) and reference it that way, putting the new prototypical instance into whatever scope necessary.

  4. #4
    Join Date
    Oct 2008
    Posts
    286

    Default

    Yes Sir,, me too... i was really amazed...

    it helps me a lot.. because all of my default values are set already in my ModelClass so that.. my initial display of my page is simply creating the new instance of ModelClass..

    maybe this is not the best practice... if any,, please post it here too..so that we may see all the options...

    thanks a lot guys..

    yoroshiku onegaishimasu..
    Eros

    Environment:
    JSP 2.0
    Dojo 1.4.1
    Ext JS 3.1 (testing)
    Spring MVC 2.5.6.SEC01 (planning to Spring 3 using STS)
    STS
    SWF 2.0.9.RELEASE
    Tiles 2.0.5
    iBatis: ibatis-sqlmap-2.3.4.726

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •