Tapestry
  1. Tapestry
  2. TAPESTRY-1991

It should be easier to access an Application State Object without forcing its creation

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.6
    • Fix Version/s: 5.0.8
    • Component/s: Framework
    • Labels:
      None

      Description

      By default an ASO is never null. It's automatically created using the ASO class default constructor.
      It's many times needed to have the null value in an ASO, for example if i want to keep the logged in user in an ASO.

      Right now we can do this by contributing a new ApplicationStateCreator to the ApplicationStateManager but it seems to me that should be as easy as providing a parameter to the @ApplicationState indicating that you don't want it to be automatically initialized.

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        If you want to avoid creating it, you can use the exists flag. For example:

        @ApplicationState
        private MyState _myState;

        private boolean _myStateExists;

        public MyState getState()

        { return _myStateExists ? _myState : null; }

        Thus, you can easily avoid creating the MyState ASO.

        Show
        Howard M. Lewis Ship added a comment - If you want to avoid creating it, you can use the exists flag. For example: @ApplicationState private MyState _myState; private boolean _myStateExists; public MyState getState() { return _myStateExists ? _myState : null; } Thus, you can easily avoid creating the MyState ASO.
        Hide
        Hugo Palma added a comment -

        How is that easier than doing:

        @ApplicationState(create=false)
        private MyState _myState;

        I'm aware of the workarounds, i just feel that without much effort this could be much simpler, the T5 way.

        Show
        Hugo Palma added a comment - How is that easier than doing: @ApplicationState(create=false) private MyState _myState; I'm aware of the workarounds, i just feel that without much effort this could be much simpler, the T5 way.
        Hide
        Howard M. Lewis Ship added a comment -

        Fair enough .... I'm just in a state of trying to get T5 into a stable, releasable state, so I'm aggressively looking to avoid more work. We can leave this open, but it probably won't be implemented for the final release, and can go into a follow-on release. The change in question would be backwards compatble (the create attribute would default to true).

        Show
        Howard M. Lewis Ship added a comment - Fair enough .... I'm just in a state of trying to get T5 into a stable, releasable state, so I'm aggressively looking to avoid more work. We can leave this open, but it probably won't be implemented for the final release, and can go into a follow-on release. The change in question would be backwards compatble (the create attribute would default to true).
        Hide
        Hugo Palma added a comment -

        Yep, agreed...

        Show
        Hugo Palma added a comment - Yep, agreed...
        Hide
        Howard M. Lewis Ship added a comment -

        This will work great the with property expression ?. operator, i.e., <t:if test="user?.loggedIn"> ... </t:iif>

        Show
        Howard M. Lewis Ship added a comment - This will work great the with property expression ?. operator, i.e., <t:if test="user?.loggedIn"> ... </t:iif>

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Hugo Palma
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development