├── .github └── workflows │ ├── deploy_4.3.2.yml │ ├── fw1_boxlang.yml_disabled │ └── fw1_java11.yml ├── .gitignore ├── Application.cfc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── box.json ├── css ├── fw1.css └── fw1logo7.jpg ├── docs └── fw1.pdf ├── examples ├── Application.cfc ├── buildurl │ ├── Application.cfc │ ├── index.cfm │ └── views │ │ └── main │ │ └── default.cfm ├── index.cfm ├── layouts │ └── default.cfm ├── modular │ ├── Application.cfc │ ├── handlers │ │ └── main.cfc │ ├── index.cfm │ ├── pages │ │ └── main │ │ │ └── default.cfm │ ├── plugins │ │ └── suba │ │ │ ├── pages │ │ │ └── main │ │ │ │ └── default.cfm │ │ │ └── wrappers │ │ │ └── default.cfm │ └── wrappers │ │ └── default.cfm ├── mustache │ ├── Application.cfc │ ├── compiler-0.9.1.jar │ ├── controllers │ │ └── main.cfc │ ├── index.cfm │ ├── layouts │ │ └── default.html │ └── views │ │ └── main │ │ ├── default.html │ │ └── page │ │ └── fragment.html ├── qBall │ ├── Application.cfc │ ├── README.md │ ├── controllers │ │ ├── main.cfc │ │ ├── question.cfc │ │ ├── security.cfc │ │ └── user.cfc │ ├── css │ │ └── style.css │ ├── images │ │ ├── heart_add.png │ │ └── heart_delete.png │ ├── index.cfm │ ├── layouts │ │ └── default.cfm │ ├── model │ │ ├── beans │ │ │ ├── answer.cfc │ │ │ ├── eventHandler.cfc │ │ │ ├── question.cfc │ │ │ └── user.cfc │ │ └── services │ │ │ ├── question.cfc │ │ │ └── user.cfc │ └── views │ │ ├── main │ │ ├── default.cfm │ │ └── error.cfm │ │ ├── question │ │ ├── error.cfm │ │ ├── list.cfm │ │ ├── new.cfm │ │ └── view.cfm │ │ └── user │ │ ├── error.cfm │ │ └── login.cfm ├── remote │ ├── AC_OETags.js │ ├── Application.cfc │ ├── fw1.html │ ├── fw1.swf │ ├── history │ │ ├── history.css │ │ ├── history.js │ │ └── historyFrame.html │ ├── index.cfm │ ├── playerProductInstall.swf │ ├── remote │ │ └── Test.cfc │ └── views │ │ └── main │ │ └── default.cfm ├── render │ ├── Application.cfc │ ├── controllers │ │ └── render.cfc │ ├── index.cfm │ └── views │ │ └── main │ │ └── default.cfm ├── rest │ ├── Application.cfc │ ├── controllers │ │ └── main.cfc │ ├── index.cfm │ └── views │ │ └── main │ │ └── default.cfm ├── skinning │ ├── Application.cfc │ ├── controllers │ │ └── skin.cfc │ ├── index.cfm │ └── skins │ │ ├── blue │ │ ├── layouts │ │ │ └── main │ │ │ │ └── second.cfm │ │ └── views │ │ │ └── main │ │ │ └── index.cfm │ │ ├── default │ │ ├── layouts │ │ │ └── default.cfm │ │ └── views │ │ │ └── main │ │ │ ├── index.cfm │ │ │ └── second.cfm │ │ └── green │ │ └── layouts │ │ └── default.cfm ├── subsystems │ ├── 1helloworld │ │ ├── Application.cfc │ │ ├── index.cfm │ │ └── views │ │ │ └── main │ │ │ └── default.cfm │ ├── 2hellolinked │ │ ├── Application.cfc │ │ ├── index.cfm │ │ └── views │ │ │ └── main │ │ │ ├── default.cfm │ │ │ └── other.cfm │ ├── 3hellolayout │ │ ├── Application.cfc │ │ ├── index.cfm │ │ ├── layouts │ │ │ ├── default.cfm │ │ │ ├── main.cfm │ │ │ └── main │ │ │ │ └── default.cfm │ │ └── views │ │ │ └── main │ │ │ ├── default.cfm │ │ │ └── other.cfm │ ├── 4hellocontroller │ │ ├── Application.cfc │ │ ├── controllers │ │ │ └── main.cfc │ │ ├── index.cfm │ │ ├── layouts │ │ │ ├── default.cfm │ │ │ ├── main.cfm │ │ │ └── main │ │ │ │ └── default.cfm │ │ └── views │ │ │ └── main │ │ │ ├── default.cfm │ │ │ └── other.cfm │ ├── 5helloservice │ │ ├── Application.cfc │ │ ├── controllers │ │ │ └── main.cfc │ │ ├── index.cfm │ │ ├── layouts │ │ │ ├── default.cfm │ │ │ ├── main.cfm │ │ │ └── main │ │ │ │ └── default.cfm │ │ ├── model │ │ │ └── services │ │ │ │ └── greeting.cfc │ │ └── views │ │ │ └── main │ │ │ ├── default.cfm │ │ │ └── other.cfm │ └── errortest │ │ ├── Application.cfc │ │ ├── controllers │ │ └── main.cfc │ │ ├── index.cfm │ │ ├── services │ │ └── main.cfc │ │ └── views │ │ └── main │ │ ├── default.cfm │ │ └── error.cfm ├── todos │ ├── Application.cfc │ ├── angular │ │ └── angular.min.js │ ├── assets │ │ └── todo.json │ ├── bootstrap │ │ ├── css │ │ │ ├── bootstrap-theme.css │ │ │ ├── bootstrap-theme.min.css │ │ │ ├── bootstrap.css │ │ │ └── bootstrap.min.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ └── glyphicons-halflings-regular.woff │ │ └── js │ │ │ ├── bootstrap.js │ │ │ └── bootstrap.min.js │ ├── controllers │ │ └── main.cfc │ ├── index.cfm │ ├── index.html │ ├── jquery │ │ ├── css │ │ │ └── ui-lightness │ │ │ │ ├── images │ │ │ │ ├── ui-bg_diagonals-thick_18_b81900_40x40.png │ │ │ │ ├── ui-bg_diagonals-thick_20_666666_40x40.png │ │ │ │ ├── ui-bg_flat_10_000000_40x100.png │ │ │ │ ├── ui-bg_glass_100_f6f6f6_1x400.png │ │ │ │ ├── ui-bg_glass_100_fdf5ce_1x400.png │ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ │ ├── ui-bg_gloss-wave_35_f6a828_500x100.png │ │ │ │ ├── ui-bg_highlight-soft_100_eeeeee_1x100.png │ │ │ │ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ ├── ui-icons_228ef1_256x240.png │ │ │ │ ├── ui-icons_ef8c08_256x240.png │ │ │ │ ├── ui-icons_ffd27a_256x240.png │ │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ │ └── jquery-ui-1.8.19.custom.css │ │ └── js │ │ │ ├── jquery-1.7.2.min.js │ │ │ ├── jquery-ui-1.8.21.custom.min.js │ │ │ ├── jquery.editinplace.js │ │ │ ├── jquery.ui.touch-punch.js │ │ │ └── jquery.validate.js │ └── model │ │ └── services │ │ └── todo.cfc ├── userManager │ ├── Application.cfc │ ├── MyApplication.cfc │ ├── assets │ │ └── css │ │ │ └── styles.css │ ├── controllers │ │ └── user.cfc │ ├── index.cfm │ ├── layouts │ │ └── default.cfm │ ├── model │ │ ├── beans │ │ │ ├── department.cfc │ │ │ └── user.cfc │ │ └── services │ │ │ ├── department.cfc │ │ │ └── user.cfc │ └── views │ │ └── user │ │ ├── default.cfm │ │ ├── form.cfm │ │ └── list.cfm ├── userManagerAJAX │ ├── Application.cfc │ ├── assets │ │ ├── css │ │ │ └── styles.css │ │ └── js │ │ │ ├── behaviors.js │ │ │ ├── jquery-1.3.2.min.js │ │ │ └── jquery-forms-2.33.js │ ├── controllers │ │ └── user.cfc │ ├── index.cfm │ ├── layouts │ │ ├── default.cfm │ │ └── user.cfm │ ├── model │ │ ├── beans │ │ │ ├── department.cfc │ │ │ └── user.cfc │ │ └── services │ │ │ ├── department.cfc │ │ │ └── user.cfc │ └── views │ │ └── user │ │ ├── default.cfm │ │ ├── form.cfm │ │ └── list.cfm ├── userManagerAccessControl │ ├── Application.cfc │ ├── assets │ │ ├── config │ │ │ ├── Application.cfm │ │ │ └── beans.xml.cfm │ │ └── css │ │ │ └── styles.css │ ├── controllers │ │ ├── login.cfc │ │ ├── main.cfc │ │ ├── security.cfc │ │ └── user.cfc │ ├── index.cfm │ ├── layouts │ │ └── default.cfm │ ├── model │ │ ├── beans │ │ │ ├── department.cfc │ │ │ ├── role.cfc │ │ │ └── user.cfc │ │ └── services │ │ │ ├── department.cfc │ │ │ ├── role.cfc │ │ │ └── user.cfc │ └── views │ │ ├── login │ │ └── default.cfm │ │ ├── main │ │ ├── default.cfm │ │ └── password.cfm │ │ └── user │ │ ├── default.cfm │ │ ├── form.cfm │ │ └── list.cfm ├── views │ └── main │ │ ├── default.cfm │ │ └── error.cfm └── wirebox │ ├── Application.cfc │ ├── controllers │ └── main.cfc │ ├── index.cfm │ ├── model │ └── friendlyservice.cfc │ └── views │ └── main │ └── default.cfm ├── framework ├── Application.cfc ├── MyApplication.cfc ├── WireBoxAdapter.cfc ├── aop.cfc ├── beanProxy.cfc ├── facade.cfc ├── ioc.cfc ├── methodProxy.cfc ├── nullObject.cfc └── one.cfc ├── index.cfm ├── introduction ├── controllers │ └── main.cfc ├── layouts │ └── default.cfm └── views │ ├── about │ └── default.cfm │ └── main │ ├── default.cfm │ ├── examples.cfm │ └── missingview.cfm ├── server.json ├── skeleton ├── Application.cfc ├── controllers │ └── main.cfc ├── index.cfm ├── layouts │ └── default.cfm ├── model │ ├── beans │ │ └── instant.cfc │ └── services │ │ └── formatter.cfc └── views │ └── main │ ├── default.cfm │ └── error.cfm └── tests ├── AddBeanTest.cfc ├── Application.cfc ├── BasicBeanTest.cfc ├── BeanInfoTest.cfc ├── CircularTest.cfc ├── CombinedInterceptorsTest.cfc ├── CombinedInterceptorsTestIssue518.cfc ├── ConstantTest.cfc ├── DeclareBeanTest.cfc ├── DisableLayoutTest.cfc ├── EmptyTest.cfc ├── ExtraBeansTest.cfc ├── FactoryBeanTest.cfc ├── InitMethodWithConstantsTest.cfc ├── InjectPropertiesTest.cfc ├── InjectableTest.cfc ├── MappingTest.cfc ├── ModelServiceTest.cfc ├── ModelTest.cfc ├── OnLoadTest.cfc ├── ParentTest.cfc ├── TransientInjectionTest.cfc ├── TransientTest.cfc ├── aop ├── interceptors │ ├── BasicInterceptor.cfc.test │ ├── aop │ │ ├── AfterInterceptor.cfc │ │ ├── AroundInterceptor.cfc │ │ ├── BeforeInterceptor.cfc │ │ ├── ErrorInterceptor.cfc │ │ └── interceptor.cfc │ └── example │ │ └── Logger.cfc └── services │ ├── Log.cfc │ ├── Reverse.cfc │ ├── advReverse.cfc │ ├── array.cfc │ ├── service.cfc │ ├── stackLogService.cfc │ └── stringService.cfc ├── circular ├── a.cfc └── b.cfc ├── coreFunctions.cfc ├── declared └── things │ ├── example.cfc │ └── myconfig.cfc ├── defaultPropertyTest.cfc ├── defaultargTest.cfc ├── extrabeans └── sheep │ ├── construct.cfc │ ├── default.cfc │ └── item.cfc ├── frameworkEnvTest.cfc ├── frameworkErrorTest.cfc ├── frameworkFacadeTest.cfc ├── frameworkPopulateTest.cfc ├── frameworkProcessRoutesTest.cfc ├── frameworkRenderTest.cfc ├── frameworkResourceRoutesTest.cfc ├── frameworkRouteTest.cfc ├── initMethod ├── Constant.cfc └── myService.cfc ├── issue408 ├── ConstructorDependancy.cfc ├── NoDependancies.cfc └── SetterDependancy.cfc ├── issue420 ├── singleton.cfc └── transient.cfc ├── issue518 ├── Log.cfc ├── daos │ └── advReverse.cfc ├── interceptors │ ├── BasicInterceptor.cfc.test │ ├── aop │ │ ├── AfterInterceptor.cfc │ │ ├── AroundInterceptor.cfc │ │ ├── BeforeInterceptor.cfc │ │ ├── ErrorInterceptor.cfc │ │ └── interceptor.cfc │ └── example │ │ └── Logger.cfc ├── service.cfc ├── services │ ├── Reverse.cfc │ ├── advReverse.cfc │ └── array.cfc ├── stackLog.cfc └── string.cfc ├── layout ├── layouts │ └── main │ │ └── default.cfm └── views │ └── main │ └── default.cfm ├── model ├── bases │ └── BaseClass.cfc ├── beans │ ├── fava.cfc │ ├── person.cfc │ ├── pinto.cfc │ ├── user2Bean.cfc │ ├── user37.cfc │ ├── user37b.cfc │ └── user37c.cfc ├── fish │ └── user.cfc └── services │ ├── factory.cfc │ ├── fava.cfc │ ├── listener.cfc │ └── product.cfc ├── omv ├── layouts │ ├── default.cfm │ └── main │ │ ├── default.cfm │ │ └── two.cfm └── views │ └── main │ └── test.cfm ├── onMissingViewLayoutTest.cfc ├── onSessionStartBuildURLTest.cfc ├── rest └── DecodeTest.cfc ├── runner.cfm ├── services └── user.cfc ├── singletonPattern ├── beans │ ├── BarService.cfc │ ├── Beer.cfc │ ├── BeerFactory.cfc │ └── Wine.cfc ├── drink │ ├── Coffee.cfc │ ├── DrinksService.cfc │ └── Tea.cfc └── food │ ├── Burger.cfc │ ├── FoodFactory.cfc │ └── Pizza.cfc ├── singletonPatternTest.cfc ├── specs └── injectPropertiesTest.cfc ├── stubs ├── Address.cfc ├── Contact.cfc ├── UserOneLevel.cfc ├── UserThreeLevel.cfc └── UserTwoLevel.cfc ├── traceRender └── one.cfc ├── transientPattern ├── beans │ ├── BarService.cfc │ ├── Beer.cfc │ ├── BeerFactory.cfc │ └── Wine.cfc ├── drink │ ├── CoffeeFoo.cfc │ ├── Drinks.cfc │ └── Tea.cfc └── food │ ├── Burger.cfc │ ├── FoodFactory.cfc │ └── PizzaFoo.cfc └── transientPatternTest.cfc /.github/workflows/deploy_4.3.2.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 4.3.2 2 | 3 | on: 4 | push: 5 | branches: [ "develop" ] 6 | pull_request: 7 | branches: [ "develop" ] 8 | 9 | workflow_dispatch: 10 | 11 | jobs: 12 | deploy: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Transfer files to fw1-4.3.2.mycfspace.org for manual review 19 | uses: SamKirkland/FTP-Deploy-Action@v4.3.4 20 | with: 21 | server: ${{ secrets.FTP_HOST_432 }} 22 | username: ${{ secrets.FTP_USER_432 }} 23 | password: ${{ secrets.FTP_PASSWORD_432 }} 24 | -------------------------------------------------------------------------------- /.github/workflows/fw1_boxlang.yml_disabled: -------------------------------------------------------------------------------- 1 | name: fw1 BoxLang 2 | 3 | on: 4 | push: 5 | branches: [ "develop" ] 6 | pull_request: 7 | branches: [ "develop" ] 8 | 9 | jobs: 10 | test: 11 | strategy: 12 | matrix: 13 | engine: [ boxlang, boxlang@be ] 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK 21 20 | uses: actions/setup-java@v3 21 | with: 22 | java-version: '21' 23 | distribution: 'temurin' 24 | 25 | - name: Install the ortus security key 26 | run: curl -fsSl https://downloads.ortussolutions.com/debs/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/ortussolutions.gpg > /dev/null 27 | 28 | - name: Add the commandbox source 29 | run: echo "deb [signed-by=/usr/share/keyrings/ortussolutions.gpg] https://downloads.ortussolutions.com/debs/noarch /" | sudo tee /etc/apt/sources.list.d/commandbox.list 30 | 31 | - name: Update apt and install commandbox 32 | run: sudo apt-get update && sudo apt-get install apt-transport-https commandbox 33 | 34 | - name: Install boxlang 35 | run: box install commandbox-boxlang 36 | 37 | - name: Start the ${{ matrix.engine }} CFML engine 38 | run: box server start cfengine=${{ matrix.engine }} port=8500 openbrowser=false javaVersion=openjdk21_jdk 39 | 40 | - name: Install bx-compat 41 | run: box install bx-compat 42 | 43 | - name: Stop boxlang after bx-compat install 44 | run: box server stop 45 | 46 | - name: Restart boxlang after bx-compat install 47 | run: box server start cfengine=${{ matrix.engine }} port=8500 openbrowser=false javaVersion=openjdk21_jdk 48 | 49 | - name: Install testbox dependency 50 | run: box install testbox 51 | 52 | - name: Run test 53 | run: | 54 | testResults="echo $(box testbox run reporter=mintext)"; 55 | echo "$testResults"; 56 | if grep -i "\[Failures: [1-9][0-9]\?[0-9]\?\]\|\[Errors: [1-9][0-9]\?[0-9]\?\]\|]*>\|]*>" <<< $testResults; then exit 1; fi 57 | -------------------------------------------------------------------------------- /.github/workflows/fw1_java11.yml: -------------------------------------------------------------------------------- 1 | name: fw1 Java 11 2 | 3 | on: 4 | push: 5 | branches: [ "develop", "5.0.0" ] 6 | pull_request: 7 | branches: [ "develop", "5.0.0" ] 8 | 9 | jobs: 10 | test: 11 | strategy: 12 | matrix: 13 | engine: [ lucee@5, adobe@2023, adobe@2021, adobe@2018 ] 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK 11 20 | uses: actions/setup-java@v3 21 | with: 22 | java-version: '11' 23 | distribution: 'temurin' 24 | 25 | - name: Install the ortus security key 26 | run: curl -fsSl https://downloads.ortussolutions.com/debs/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/ortussolutions.gpg > /dev/null 27 | 28 | - name: Add the commandbox source 29 | run: echo "deb [signed-by=/usr/share/keyrings/ortussolutions.gpg] https://downloads.ortussolutions.com/debs/noarch /" | sudo tee /etc/apt/sources.list.d/commandbox.list 30 | 31 | - name: Update apt and install commandbox 32 | run: sudo apt-get update && sudo apt-get install apt-transport-https commandbox 33 | 34 | - name: Install dependencies 35 | run: box install 36 | 37 | - name: Start the ${{ matrix.engine }} CFML engine 38 | run: box server start cfengine=${{ matrix.engine }} port=8500 openbrowser=false 39 | 40 | - name: Run test 41 | run: | 42 | testResults="echo $(box testbox run reporter=mintext)"; 43 | echo "$testResults"; 44 | if grep -i "\[Failures: [1-9][0-9]\?[0-9]\?\]\|\[Errors: [1-9][0-9]\?[0-9]\?\]\|]*>\|]*>" <<< $testResults; then exit 1; fi 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | WEB-INF/* 2 | wirebox/* 3 | testbox/* 4 | tests/results/ 5 | .project 6 | settings.xml 7 | .settings/org.eclipse.core.resources.prefs 8 | # Intellij IDEA files 9 | *.iml 10 | *.ipr 11 | *.idea 12 | run-tests.sh 13 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Framework One Contributor Code of Conduct 2 | 3 | As contributors and maintainers of FW/1 or any Framework One asset, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in Framework One a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 6 | 7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 8 | 9 | Framework One maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Framework One maintainers who do not follow the Code of Conduct may be removed from the project team. 10 | 11 | This code of conduct applies both within project spaces and in public spaces when an individual is representing the Framework One or its community. 12 | 13 | Instances of abusive, harassing, or otherwise unacceptable behavior should be immediately reported on the [mailing list](https://groups.google.com/forum/?fromgroups#!forum/framework-one) or by contacting Sean Corfield via [email](mailto:sean@corfield.org) or [Twitter](https://twitter.com/seancorfield). 14 | 15 | This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to Framework One (FW/1, DI/1, AOP/1) 2 | == 3 | Please note that in order to encourage more people to get involved with Framework One, we have adopted a [Code of Conduct](CODE_OF_CONDUCT.md) so that _everyone_ should feel welcome and safe when getting involved with any aspect of the Framework One community. 4 | 5 | All development happens in the main [Framework One repository](https://github.com/framework-one/fw1) on the **develop** branch. Feel free to fork the repo and submit Pull Requests on the **develop** branch. You can also open issues there to discuss potential enhancements etc. 6 | 7 | You can also discuss bugs and enhancements on [Gitter](https://gitter.im/framework-one/fw1) or [Slack](https://cfml.slack.com/messages/fw1/). You can sign into Gitter directly using your GitHub credentials. For Slack, you'll need to [request an account](http://cfml-slack.herokuapp.com/). 8 | 9 | Pull Requests that contain new/updated tests for the bug fix / enhancement will be looked on more favorably than those that do not contain fixes. Github Workflows automatically runs the test suite for Pull Requests which helps us be confident that the Pull Request is "good". 10 | 11 | Please follow the same formatting as the existing code, especially in terms of spacing around operators, parentheses, braces and so on. If in doubt, ask on the mailing list. 12 | 13 | By submitting a Pull Request, you are granting copyright license to Sean Corfield and that your submission may be legally released under the Apache Source License 2.0 (http://www.apache.org/licenses/LICENSE-2.0). 14 | 15 | The **master** branch represents the current stable release of FW/1. Do not submit Pull Requests against **master**. Showstopping bugs should be raised as issues and fixes will be applied to **develop** (if appropriate) and backported to **master** manually. 16 | 17 | **Note:** Do not submit Pull Requests against [Sean's personal fork](https://github.com/seancorfield/fw1) - that exists for historical reasons and Github doesn't let you turn Pull Requests off. 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2018, Sean Corfield (see individual files for any 2 | additional copyright holders) 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /box.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"Framework One", 3 | "slug":"fw1", 4 | "version":"4.3.0", 5 | "author":"Sean Corfield, Marcin Szczepanski, Ryan Cogswell", 6 | "location":"framework-one/fw1#develop", 7 | "createPackageDirectory":true, 8 | "packageDirectory":"framework", 9 | "Homepage":"http://framework-one.github.io/", 10 | "Documentation":"http://framework-one.github.io/documentation/", 11 | "Repository":{ 12 | "type":"git", 13 | "URL":"https://github.com/framework-one/fw1.git" 14 | }, 15 | "Bugs":"https://github.com/framework-one/fw1/issues", 16 | "shortDescription":"FW/1 - Framework One - is a family of small, lightweight, convention-over-configuration frameworks, primarily for CFML.", 17 | "description":"FW/1 - Framework One - is a family of small, lightweight, convention-over-configuration frameworks, primarily for CFML. FW/1 itself provides MVC, DI/1 provides dependency injection (a.k.a. inversion of control), and AOP/1 provides aspect-oriented programming features on top of DI/1.", 18 | "instructions":"http://framework-one.github.io/documentation/", 19 | "changelog":"https://github.com/framework-one/fw1/commits/develop", 20 | "type":"mvc", 21 | "keywords":[ 22 | "fw1", 23 | "framework one", 24 | "mvc", 25 | "conventions" 26 | ], 27 | "private":"false", 28 | "engines":[ 29 | { 30 | "type":"railo", 31 | "version":">=4.1.x" 32 | }, 33 | { 34 | "type":"lucee", 35 | "version":">=4.5.x" 36 | }, 37 | { 38 | "type":"adobe", 39 | "version":">=10.0.x" 40 | } 41 | ], 42 | "License":[ 43 | { 44 | "type":"Apache 2.0", 45 | "URL":"http://www.apache.org/licenses/LICENSE-2.0" 46 | } 47 | ], 48 | "Contributors":[ 49 | { 50 | "name":"Contributors List", 51 | "url":"https://github.com/framework-one/fw1/graphs/contributors" 52 | } 53 | ], 54 | "ignore":[ 55 | 56 | ], 57 | "devDependencies":{ 58 | "testbox":"2.5.0+107" 59 | }, 60 | "installPaths":{ 61 | "testbox":"testbox" 62 | }, 63 | "testbox":{ 64 | "runner":"http://localhost:8500/tests/runner.cfm" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /css/fw1.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | } 4 | .wrap { 5 | border: green 2px solid; 6 | margin: 5px; 7 | padding: 5px; 8 | font-family: verdana, helvetica; 9 | } 10 | .page { 11 | padding: 5px; 12 | } 13 | .footer { 14 | text-align: center; 15 | font-size: small; 16 | } -------------------------------------------------------------------------------- /css/fw1logo7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/css/fw1logo7.jpg -------------------------------------------------------------------------------- /docs/fw1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/docs/fw1.pdf -------------------------------------------------------------------------------- /examples/buildurl/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | variables.framework = { generateSES = true }; 3 | } 4 | -------------------------------------------------------------------------------- /examples/buildurl/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/buildurl/index.cfm -------------------------------------------------------------------------------- /examples/buildurl/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Testbed for buildURL()

3 |

buildURL('')

4 |

buildURL('.')

5 |

buildURL(':') -- only valid in a subsystem-based app

6 |

buildURL('main.default')

7 |

buildURL('main.default##anchor')

8 |

buildURL('main.default?##anchor')

9 |

buildURL('main.default??##anchor')

10 |

buildURL('main.default?test=1')

11 |

buildURL('main.default?test=1##anchor')

12 |

buildURL('main.default??test=2')

13 |

buildURL('main.default??test=2##anchor')

14 |

buildURL(action='main.default',queryString='##anchor')

15 |

buildURL(action='main.default',queryString='?##anchor')

16 |

buildURL(action='main.default',queryString='test=1')

17 |

buildURL(action='main.default',queryString='test=1##anchor')

18 |

buildURL(action='main.default',queryString='?test=2')

19 |

buildURL(action='main.default',queryString='?test=2##anchor')

20 |
21 | -------------------------------------------------------------------------------- /examples/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/index.cfm -------------------------------------------------------------------------------- /examples/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | FW/1 - Framework One - Examples 7 | " /> 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | #body# 16 |

Examples Home

17 |
18 |
19 | FW/1 is copyright (c) 2009-#year( now() )#, Sean Corfield, Marcin Szczepanski, Ryan Cogswell - 20 | Licensed under the Apache License, Version 2.0
21 | You are running FW/1 version #variables.framework.version# on #server.coldfusion.productname & " " & 22 | ( structKeyExists( server, "lucee" ) ? 23 | server.lucee.version & " / " : "" ) & 24 | server.coldfusion.productversion#. 25 |
26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/modular/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends=framework.one { 2 | variables.framework = { 3 | trace : true, 4 | controllersFolder : "handlers", 5 | layoutsFolder : "wrappers", 6 | subsystemsFolder : "plugins", 7 | viewsFolder : "pages" 8 | }; 9 | function setupView( rc ) { 10 | rc.message = "Rendered by FW/1 version " & variables.framework.version; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/modular/handlers/main.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | property framework; 3 | function default( rc ) { 4 | rc.handlerSays = "This message brought to you by " & 5 | framework.getConfig().controllersFolder & "/main.cfc!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/modular/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/modular/index.cfm -------------------------------------------------------------------------------- /examples/modular/pages/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

I am the main page!

3 |

#rc.handlerSays#

4 |

Go to suba:main.default

5 |
6 | -------------------------------------------------------------------------------- /examples/modular/plugins/suba/pages/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

I am subsystem A!

3 |

Go back home!

4 |
5 | -------------------------------------------------------------------------------- /examples/modular/plugins/suba/wrappers/default.cfm: -------------------------------------------------------------------------------- 1 |

Subsystem A Default Wrapper

2 | #body# 3 | -------------------------------------------------------------------------------- /examples/modular/wrappers/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Default Wrapper

3 |
4 | #body# 5 |
6 |

#rc.message#

7 |
8 | -------------------------------------------------------------------------------- /examples/mustache/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends=framework.one { 2 | 3 | variables.mustacheJAR = expandPath( "compiler-0.9.1.jar" ); 4 | this.javaSettings.loadPaths = [ variables.mustacheJAR ]; 5 | 6 | function setupApplication() { 7 | var mustacheFactory = "com.github.mustachejava.DefaultMustacheFactory"; 8 | var viewRoot = expandPath( "/" ); 9 | application.mustache = createObject( 10 | "java", mustacheFactory 11 | ).init( 12 | createObject( "java", "java.io.File" ).init( viewRoot ) 13 | ); 14 | } 15 | 16 | function setupView( rc ) { 17 | variables.mustacheProxies = makeMethodProxies( [ "buildURL", "view" ] ); 18 | } 19 | 20 | // we must override this to change the file extension that FW/1 looks for: 21 | public string function customizeViewOrLayoutPath( struct pathInfo, string type, string fullPath ) { 22 | return '#pathInfo.base##type#s/#pathInfo.path#.html'; 23 | } 24 | 25 | public any function customTemplateEngine( string type, string path, struct scope ) { 26 | // so mustache can see these functions: 27 | scope.fw1 = variables.mustacheProxies; 28 | // compile & execute the template: 29 | var template = application.mustache.compile( path ); 30 | var writer = createObject( "java", "java.io.StringWriter" ).init(); 31 | template.execute( writer, [ scope ] ); 32 | writer.flush(); 33 | return writer.toString(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /examples/mustache/compiler-0.9.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/mustache/compiler-0.9.1.jar -------------------------------------------------------------------------------- /examples/mustache/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function default( rc ) { 4 | rc.numbers = [1,2,3,4]; 5 | rc.productversion = 6 | server.coldfusion.productname & " " & 7 | ( structKeyExists( server, "lucee" ) ? 8 | server.lucee.version & " / " : "" ) & 9 | server.coldfusion.productversion; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /examples/mustache/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/mustache/index.cfm -------------------------------------------------------------------------------- /examples/mustache/layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mustache Layout 4 | 5 | 6 |

7 | We use the triple mustache delimiters around body so that the HTML 8 | it contains is not escaped. 9 |

10 |
11 | {{{body}}} 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/mustache/views/main/default.html: -------------------------------------------------------------------------------- 1 |

Hello from Mustache!

2 |

Your name is {{rc.name}}!

3 |
    4 | {{#rc.numbers}} 5 |
  • {{.}}
  • 6 | {{/rc.numbers}} 7 |
8 |

Call a FW/1 function to generate a link: Linked Page!

9 |

Load a fragment via Mustache partial (page-relative): {{> page/fragment}}

10 |

Load a fragment via FW/1's view (views-root-relative): {{#fw1.view}}main/page/fragment{{/fw1.view}}

11 |

Powered by {{rc.productversion}}.

12 | -------------------------------------------------------------------------------- /examples/mustache/views/main/page/fragment.html: -------------------------------------------------------------------------------- 1 | This is a page fragment! 2 | -------------------------------------------------------------------------------- /examples/qBall/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | this.name = "qball"; 4 | this.sessionManagement = true; 5 | this.sessionTimeout = createTimeSpan(0,2,0,0); 6 | this.dataSource = this.name; 7 | this.ormEnabled = true; 8 | this.ormsettings = { 9 | cfclocation="./model/beans", 10 | dbcreate="update", // update database tables only 11 | dialect="MySQL", // assume MySql, other dialects available http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html 12 | eventhandling="true", 13 | eventhandler="root.model.beans.eventhandler", 14 | logsql="true" 15 | }; 16 | 17 | this.mappings["/root"] = getDirectoryFromPath(getCurrentTemplatePath()); 18 | 19 | variables.framework = { 20 | diLocations = "./model/services", // ColdFusion ORM handles Beans 21 | reloadApplicationOnEveryRequest = "true", 22 | trace = "false" 23 | }; 24 | 25 | public function setupSession() { 26 | controller('security.session'); 27 | } 28 | 29 | public function setupRequest() { 30 | if(structKeyExists(url, "init")) { // use index.cfm?init to reload ORM 31 | setupApplication(); 32 | ormReload(); 33 | location(url="index.cfm",addToken=false); 34 | } 35 | 36 | controller("security.authorize"); 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /examples/qBall/README.md: -------------------------------------------------------------------------------- 1 | Framework One Sample Application - QBall 2 | Raymond Camden 2010 3 | http://www.raymondcamden.com/index.cfm/2010/2/27/Framework-One-Sample-Application--QBall 4 | Updated and included in FW/1 (with permission) by Jeremey Hustman 2014 5 | 6 | ** Using ColdFusion ORM is not recommended, but it does work. ** 7 | 8 | This is an example application that uses Framework One (FW/1) and ColdFusion ORM (tested on both Adobe and Railo). 9 | 10 | You must first create a datasource 'qBall' in ColdFusion administrator pointing to an empty MySql database. 11 | 12 | If using a database other than MySql, adjust your dialect settings in Application.cfc 'this.ormsettings' to reflect your environment. 13 | -------------------------------------------------------------------------------- /examples/qBall/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * I am the main controller. 3 | */ 4 | component accessors="true" { 5 | 6 | property question; 7 | 8 | public function init(fw) { 9 | variables.fw = fw; 10 | } 11 | 12 | public function default(rc) { 13 | rc.questions = variables.question.list(perpage=5); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /examples/qBall/controllers/security.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * I am the Security controller 3 | */ 4 | component { 5 | 6 | function init( fw ) { 7 | variables.fw = fw; 8 | } 9 | 10 | function session( rc ) { 11 | // set up the user's session 12 | session.auth = {}; 13 | session.auth.isLoggedIn = false; 14 | session.auth.userId = '0'; 15 | session.auth.userName = 'Guest'; 16 | } 17 | 18 | function authorize( rc ) { 19 | // check to make sure the user is logged on 20 | if ( !session.auth.isLoggedIn && 21 | not listfindnocase( 'main.default', variables.fw.getFullyQualifiedAction() ) && 22 | not listfindnocase( 'user.login', variables.fw.getFullyQualifiedAction() ) && 23 | not listfindnocase( 'user.register', variables.fw.getFullyQualifiedAction() ) && 24 | not listfindnocase( 'user.authenticate', variables.fw.getFullyQualifiedAction() ) && 25 | not listfindnocase( 'main.error', variables.fw.getFullyQualifiedAction() ) ) { 26 | variables.fw.redirect('main.default'); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /examples/qBall/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #cccc99; 3 | font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; 4 | } 5 | 6 | #header { 7 | width: 70%; 8 | margin-left: auto; 9 | margin-right: auto; 10 | background-color: white; 11 | padding: 5px; 12 | } 13 | 14 | #body { 15 | width: 70%; 16 | margin-top: 10px; 17 | margin-left: auto; 18 | margin-right: auto; 19 | background-color: white; 20 | padding: 5px; 21 | } 22 | 23 | .answer, .answerOdd, .selectedAnswer { 24 | padding: 5px; 25 | border-width:1px; 26 | border-style: solid; 27 | margin-bottom: 5px; 28 | } 29 | 30 | .answerOdd { 31 | background-color: #eeeeee; 32 | } 33 | 34 | .selectedAnswer { 35 | background-color: #66cc99; 36 | } 37 | 38 | .pagination { 39 | text-align: right; 40 | } -------------------------------------------------------------------------------- /examples/qBall/images/heart_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/qBall/images/heart_add.png -------------------------------------------------------------------------------- /examples/qBall/images/heart_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/qBall/images/heart_delete.png -------------------------------------------------------------------------------- /examples/qBall/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/qBall/index.cfm -------------------------------------------------------------------------------- /examples/qBall/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | #rc.pagetitle# 9 | 10 | 11 | 12 | 22 | 23 |
24 | 25 |
26 |
27 | #body# 28 |
29 | 30 | 31 | 32 |
33 | 34 | 40 | -------------------------------------------------------------------------------- /examples/qBall/model/beans/answer.cfc: -------------------------------------------------------------------------------- 1 | component persistent="true" accessors="true" { 2 | 3 | property name="id" generator="native" ormtype="integer" fieldtype="id"; 4 | property name="text" ormtype="text"; 5 | property name="selectedanswer" ormtype="boolean"; 6 | property name="created" ormtype="timestamp"; 7 | property name="edited" ormtype="timestamp"; 8 | 9 | // Relationships 10 | property name="user" fieldType="many-to-one" cfc="user" 11 | fkcolumn="useridfk"; 12 | 13 | //used for votes, hate the name 14 | property name="approvers" fieldType="many-to-many" cfc="user" 15 | linktable="approvedanswers_user" fkcolumn="answeridfk" 16 | inversejoincolumn="useridfk" lazy="extra" 17 | singularname="approver"; 18 | 19 | property name="disapprovers" fieldType="many-to-many" cfc="user" 20 | linktable="disapprovedanswers_user" fkcolumn="answeridfk" 21 | inversejoincolumn="useridfk" lazy="extra" 22 | singularname="disapprover"; 23 | 24 | 25 | public function getSelectedAnswer() { 26 | if(isNull(variables.selectedanswer) || !isBoolean(variables.selectedanswer)) return false; 27 | else return variables.selectedanswer; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /examples/qBall/model/beans/eventHandler.cfc: -------------------------------------------------------------------------------- 1 | component implements="CFIDE.orm.IEventHandler" { 2 | 3 | public void function preDelete(any entity) { 4 | 5 | } 6 | 7 | public void function preInsert(any entity) { 8 | //only run if we have both audit cols 9 | if(structKeyExists(arguments.entity, "setCreated") && structKeyExists(arguments.entity, "setEdited")) { 10 | arguments.entity.setCreated(now()); 11 | arguments.entity.setEdited(now()); 12 | } 13 | } 14 | 15 | public void function preUpdate(any entity, struct oldData) { 16 | //only run if we have both audit cols 17 | if(structKeyExists(arguments.entity, "setCreated") && structKeyExists(arguments.entity, "setEdited")) { 18 | arguments.entity.setEdited(now()); 19 | } 20 | } 21 | 22 | public void function preLoad( any entity) { 23 | 24 | } 25 | 26 | public void function postDelete( any entity) { 27 | 28 | } 29 | 30 | public void function postLoad( any entity) { 31 | 32 | } 33 | 34 | public void function postUpdate( any entity) { 35 | 36 | } 37 | 38 | public void function postInsert( any entity) { 39 | 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /examples/qBall/model/beans/question.cfc: -------------------------------------------------------------------------------- 1 | component persistent="true" accessors="true" { 2 | 3 | property name="id" generator="native" ormtype="integer" fieldtype="id"; 4 | property name="title" ormtype="string" length="255"; 5 | property name="text" ormtype="text"; 6 | property name="created" ormtype="timestamp"; 7 | property name="edited" ormtype="timestamp"; 8 | 9 | // Relationships 10 | property name="user" fieldType="many-to-one" cfc="user" 11 | fkcolumn="useridfk"; 12 | 13 | property name="answers" fieldType="many-to-many" cfc="answer" 14 | linktable="question_answer" fkcolumn="questionidfk" 15 | inversejoincolumn="answeridfk" lazy="true" 16 | singularname="answer"; 17 | 18 | public function getAnswered() { 19 | var hql = " 20 | select a.id 21 | from question q join q.answers a 22 | where a.selectedanswer = 1 and q.id = ? 23 | "; 24 | var r = ormExecuteQuery(hql, [variables.id]); 25 | return arrayLen(r) is 1; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/qBall/model/beans/user.cfc: -------------------------------------------------------------------------------- 1 | component persistent="true" table="users" accessors="true" { 2 | 3 | property name="id" generator="native" ormtype="integer" fieldtype="id"; 4 | property name="username" ormtype="string" length="50"; 5 | property name="password" ormtype="string" length="50"; 6 | property name="emailaddress" ormtype="string" length="255"; 7 | 8 | property name="created" ormtype="timestamp"; 9 | property name="edited" ormtype="timestamp"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /examples/qBall/model/services/user.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * I am the User service. 3 | */ 4 | component { 5 | 6 | variables.lock_name = "userlock"; 7 | 8 | public any function authenticate(string username, string password) { 9 | writeLog(file='application',text='checking #username#/#password#'); 10 | var user = entityLoad("user", {username=#username#, password=#password#},true); 11 | if(!isNull(user)) { 12 | session.auth.userid = user.getId(); 13 | session.auth.username = user.getUserName(); 14 | return user; 15 | } 16 | } 17 | 18 | public boolean function exists(string username) { 19 | var userCheck = entityLoad("user", {username=arguments.username}); 20 | if(arrayLen(userCheck) == 1) return true; 21 | return false; 22 | } 23 | 24 | public function get(numeric id) { 25 | return entityLoadByPk("user", arguments.id); 26 | } 27 | 28 | public any function register(string username,string password, string email) { 29 | writeLog(file='application',text='running SERVICE user.register() #serializejson(arguments)#'); 30 | lock name="#variables.lock_name#" type="exclusive" timeout=30 { 31 | if(exists(arguments.username)) return "User already exists."; 32 | var user = entityNew("user"); 33 | user.setUsername(arguments.username); 34 | user.setPassword(arguments.password); 35 | user.setEmailAddress(arguments.email); 36 | entitySave(user); 37 | return user; 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /examples/qBall/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Welcome to QBall

4 |

QBall is an question and answer application. Users can write questions or 5 | respond to others. Users can also rate answers up and down.

6 | 7 | 8 |

9 | Ask a Question! 10 |

11 | 12 |

13 | To ask your own question (or respond to others), please 14 | login or register. 15 |

16 |
17 | 18 |

Recent Questions

19 | 20 | 21 | 22 |

23 | #q.getTitle()# 24 | 25 | Answered 26 | 27 |
28 | Asked by #q.getUser().getUsername()# on 29 | #dateFormat(q.getCreated(), "mmmm d, yyyy")# at 30 | #timeFormat(q.getCreated(), "h:mm tt")# 31 |

32 |
33 | 34 |

35 | There are no questions currently. 36 |

37 |
38 |
39 | -------------------------------------------------------------------------------- /examples/qBall/views/main/error.cfm: -------------------------------------------------------------------------------- 1 | 

An Error Occurred

2 |

I am the application error view: main.error (in errortest).

3 |

Details of the exception:

4 | 5 |
    6 |
  • Failed action: #request.failedAction#unknown
  • 7 |
  • Application event: #request.event#
  • 8 |
  • Exception type: #request.exception.type#
  • 9 |
  • Exception message: #request.exception.message#
  • 10 |
  • Exception detail: #request.exception.detail#
  • 11 |
  • Failed Method: #request.failedMethod#unknown
  • 12 |
  • Exeption:
  • 13 |
  • rc:
  • 14 |
15 |
16 | -------------------------------------------------------------------------------- /examples/qBall/views/question/error.cfm: -------------------------------------------------------------------------------- 1 | 

An Error Occurred

2 |

I am the application error view: main.error (in errortest).

3 |

Details of the exception:

4 | 5 |
    6 |
  • Failed action: #request.failedAction#unknown
  • 7 |
  • Application event: #request.event#
  • 8 |
  • Exception type: #request.exception.type#
  • 9 |
  • Exception message: #request.exception.message#
  • 10 |
  • Exception detail: #request.exception.detail#
  • 11 |
12 |
13 | -------------------------------------------------------------------------------- /examples/qBall/views/question/list.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

All Questions

9 | 10 | 11 |

12 | Sorry, there are no questions! 13 |

14 | 15 | 16 | 17 | 18 |

19 | 20 | Previous 21 | 22 | Previous 23 | 24 | - 25 | 26 | Next 27 | 28 | Next 29 | 30 |

31 |
32 |
33 | 34 | 35 |

36 | 37 | #q.getTitle()# Answered
38 | Asked by #q.getUser().getUsername()# on #dateFormat(q.getCreated(), "mmmm d, yyyy")# at #timeFormat(q.getCreated(), "h:mm tt")# 39 |
40 |

41 |
42 | 43 | 44 |
45 | -------------------------------------------------------------------------------- /examples/qBall/views/question/new.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Ask a Question

6 | 7 | 8 |

9 | Your question coult not be posted due to the following error(s):
10 |

    11 | 12 |
  • #e#
  • 13 |
    14 |
15 |
16 | 17 | 18 |
19 |

20 | Give your question a simple, appropriate title.
21 | 22 |

23 | 24 |

25 | Now enter the text of your question. Be as clear as possible.
26 | 27 |

28 | 29 |

30 | 31 |

32 |
33 |
34 | -------------------------------------------------------------------------------- /examples/qBall/views/user/error.cfm: -------------------------------------------------------------------------------- 1 | 

An Error Occurred

2 |

I am the application error view: user.error.

3 |

Details of the exception:

4 | 5 |
    6 |
  • Failed action: #request.failedAction#unknown
  • 7 |
  • Application event: #request.event#
  • 8 |
  • Exception type: #request.exception.type#
  • 9 |
  • Exception message: #request.exception.message#
  • 10 |
  • Exception detail: #request.exception.detail#
  • 11 |
  • Failure: #request.failure#
  • 12 |
13 |
14 | -------------------------------------------------------------------------------- /examples/qBall/views/user/login.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Login

8 |

9 | Existing users can login using the form below: 10 |

11 | 12 |

13 | Your login could not be completed due to the following error(s):
14 |

    15 | 16 |
  • #e#
  • 17 |
    18 |
19 |
20 | 21 |
22 | username:
23 | password:
24 | 25 |
26 | 27 |

Register

28 |

29 | New users can register using the form below. All fields are required. 30 |

31 | 32 |

33 | Your registration could not be completed due to the following error(s):
34 |

    35 | 36 |
  • #e#
  • 37 |
    38 |
39 |
40 | 41 |
42 | username:
43 | password:
44 | confirm password:
45 | email:
46 | 47 |
48 |
49 | -------------------------------------------------------------------------------- /examples/remote/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | this.name = 'fw1-remote'; 3 | } 4 | -------------------------------------------------------------------------------- /examples/remote/fw1.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/remote/fw1.swf -------------------------------------------------------------------------------- /examples/remote/history/history.css: -------------------------------------------------------------------------------- 1 | /* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */ 2 | 3 | #ie_historyFrame { width: 0px; height: 0px; display:none } 4 | #firefox_anchorDiv { width: 0px; height: 0px; display:none } 5 | #safari_formDiv { width: 0px; height: 0px; display:none } 6 | #safari_rememberDiv { width: 0px; height: 0px; display:none } 7 | -------------------------------------------------------------------------------- /examples/remote/history/historyFrame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 27 | Hidden frame for Browser History support. 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/remote/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/remote/index.cfm -------------------------------------------------------------------------------- /examples/remote/playerProductInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/remote/playerProductInstall.swf -------------------------------------------------------------------------------- /examples/remote/remote/Test.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | remote string function test() { 3 | return "Test Succeeded"; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/remote/views/main/default.cfm: -------------------------------------------------------------------------------- 1 |

Test Remote Method Call Through FW/1

2 |

Simple in browser invocation!

3 | 4 | 5 | 6 |

Web Service call: #ws.test()#

7 |
8 | 9 |

Web Service call failed :(

10 | 11 |
12 |
13 |

Try the Flex test!

-------------------------------------------------------------------------------- /examples/render/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | variables.framework = { 3 | trace = true 4 | }; 5 | } 6 | -------------------------------------------------------------------------------- /examples/render/controllers/render.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | public any function init( any fw ) { 4 | variables.fw = fw; 5 | return this; 6 | } 7 | 8 | public void function someText( struct rc ) { 9 | variables.fw.renderData( 'text', 'This should just be plain text' ); 10 | } 11 | 12 | public void function xmlString( struct rc ) { 13 | variables.fw.renderData( 'xml', 'And a body!' ); 14 | } 15 | 16 | public void function xmlObject( struct rc ) { 17 | var xmlData = xmlParse( 'And a body!' ); 18 | variables.fw.renderData( 'xml', xmlData ); 19 | } 20 | 21 | public void function jsonObject( struct rc ) { 22 | variables.fw.renderData( 'json', [ "An", "array", { "containing" = "data" } ] ); 23 | } 24 | 25 | public void function jsonString( struct rc ) { 26 | variables.fw.renderData( 'rawjson', '[ "An", "array", { "containing" = "data" } ]' ); 27 | } 28 | 29 | public void function html( struct rc ) { 30 | variables.fw.renderData( 'html', '

Some HTML

Passed to renderData().

' ); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /examples/render/index.cfm: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/render/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

RenderData Example

3 |

Render some plain text

4 |

Render an XML string

5 |

Render an XML object

6 |

Render object as JSON

7 |

Render raw JSON (pre-serialized)

8 |

Render HTML

9 |
10 | -------------------------------------------------------------------------------- /examples/rest/Application.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | this.name = 'fw1-examples-rest'; 3 | this.mappings[ '/framework' ] = expandPath( '../framework' ); 4 | 5 | function _get_framework_one() { 6 | if ( !structKeyExists( request, '_framework_one' ) ) { 7 | request._framework_one = new framework.one( { 8 | decodeRequestBody = true, 9 | reloadApplicationOnEveryRequest = true 10 | } ); 11 | } 12 | return request._framework_one; 13 | } 14 | 15 | // delegation of lifecycle methods to FW/1: 16 | function onApplicationStart() { 17 | return _get_framework_one().onApplicationStart(); 18 | } 19 | function onError( exception, event ) { 20 | return _get_framework_one().onError( exception, event ); 21 | } 22 | function onRequest( targetPath ) { 23 | return _get_framework_one().onRequest( targetPath ); 24 | } 25 | function onRequestEnd() { 26 | return _get_framework_one().onRequestEnd(); 27 | } 28 | function onRequestStart( targetPath ) { 29 | return _get_framework_one().onRequestStart( targetPath ); 30 | } 31 | function onSessionStart() { 32 | return _get_framework_one().onSessionStart(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/rest/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init( any fw ) { 4 | variables.fw = fw; 5 | return this; 6 | } 7 | 8 | function patch( struct rc, struct headers ) { 9 | var response = { 10 | "method": "PATCH", 11 | "multi": rc.multi, 12 | "single": rc.single 13 | }; 14 | variables.fw.renderData().type( 'json' ).data( response ); 15 | } 16 | 17 | function post( struct rc, struct headers ) { 18 | var response = { 19 | "method": "POST", 20 | "multi": rc.multi, 21 | "single": rc.single 22 | }; 23 | variables.fw.renderData().type( 'json' ).data( response ); 24 | } 25 | 26 | function put( struct rc, struct headers ) { 27 | var response = { 28 | "method": "PUT", 29 | "multi": rc.multi, 30 | "single": rc.single 31 | }; 32 | variables.fw.renderData().type( 'json' ).data( response ); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /examples/rest/index.cfm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/rest/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | This rest example is used by the tests to assert that data is decoded as expected -------------------------------------------------------------------------------- /examples/skinning/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | this.sessionManagement = true; 4 | 5 | variables.framework = structNew(); 6 | variables.framework.defaultItem = 'index'; 7 | 8 | function setupRequest() { 9 | controller( 'skin' ); 10 | } 11 | 12 | function customizeViewOrLayoutPath( pathInfo, type, fullPath ) { 13 | // fullPath is: '#pathInfo.base##type#s/#pathInfo.path#.cfm' 14 | var defaultPath = '#type#s/#pathInfo.path#.cfm'; 15 | 16 | if ( fileExists( expandPath( request.subsystembase & '/skins/' & request.context.skin & '/' & defaultPath ) ) ) { 17 | return request.subsystembase & 'skins/' & request.context.skin & '/' & defaultPath; 18 | } else { 19 | return request.subsystembase & 'skins/default/' & defaultPath; 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /examples/skinning/controllers/skin.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function before( rc ) { 4 | // change skin if specified: 5 | if ( structKeyExists( rc, 'skin' ) ) { 6 | session.skin = rc.skin; 7 | } 8 | // set skin for each request: 9 | if ( structKeyExists( session, 'skin' ) ) { 10 | rc.skin = session.skin; 11 | } else { 12 | rc.skin = 'default'; 13 | } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /examples/skinning/index.cfm: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /examples/skinning/skins/blue/layouts/main/second.cfm: -------------------------------------------------------------------------------- 1 |  6 | 7 | #body# 8 |

I'm a custom blue layout for the second page.

9 |
-------------------------------------------------------------------------------- /examples/skinning/skins/blue/views/main/index.cfm: -------------------------------------------------------------------------------- 1 | 

This is the blue default page.

-------------------------------------------------------------------------------- /examples/skinning/skins/default/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 

This is the default layout.

2 | 3 | #body# 4 |

Go to 5 | default page | 6 | second page.

7 |

Select skin: 8 | blue | 9 | green | 10 | default.

11 |
-------------------------------------------------------------------------------- /examples/skinning/skins/default/views/main/index.cfm: -------------------------------------------------------------------------------- 1 | 

This is the default page.

-------------------------------------------------------------------------------- /examples/skinning/skins/default/views/main/second.cfm: -------------------------------------------------------------------------------- 1 | 

I'm the second page.

-------------------------------------------------------------------------------- /examples/skinning/skins/green/layouts/default.cfm: -------------------------------------------------------------------------------- 1 |  6 |

This is the green layout.

7 | 8 | #body# 9 |

Go to 10 | default page | 11 | second page.

12 |

Select skin: 13 | blue | 14 | green | 15 | default.

16 |
-------------------------------------------------------------------------------- /examples/subsystems/1helloworld/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends=framework.one { 2 | } 3 | -------------------------------------------------------------------------------- /examples/subsystems/1helloworld/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/subsystems/1helloworld/index.cfm -------------------------------------------------------------------------------- /examples/subsystems/1helloworld/views/main/default.cfm: -------------------------------------------------------------------------------- 1 |

Hello FW/1!

-------------------------------------------------------------------------------- /examples/subsystems/2hellolinked/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends=framework.one { 2 | } 3 | -------------------------------------------------------------------------------- /examples/subsystems/2hellolinked/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/subsystems/2hellolinked/index.cfm -------------------------------------------------------------------------------- /examples/subsystems/2hellolinked/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Hello FW1!

3 |

Go away!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/2hellolinked/views/main/other.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Goodbye FW/1!

3 |

Come back!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/3hellolayout/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends=framework.one { 2 | } 3 | -------------------------------------------------------------------------------- /examples/subsystems/3hellolayout/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/subsystems/3hellolayout/index.cfm -------------------------------------------------------------------------------- /examples/subsystems/3hellolayout/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |
3 | #body# 4 |
5 |
6 | -------------------------------------------------------------------------------- /examples/subsystems/3hellolayout/layouts/main.cfm: -------------------------------------------------------------------------------- 1 |
#body#
2 | -------------------------------------------------------------------------------- /examples/subsystems/3hellolayout/layouts/main/default.cfm: -------------------------------------------------------------------------------- 1 |

Welcome to FW/1!

2 | #body# 3 | -------------------------------------------------------------------------------- /examples/subsystems/3hellolayout/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Hello FW1!

3 |

Go away!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/3hellolayout/views/main/other.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Goodbye FW/1!

3 |

Come back!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends=framework.one { 2 | } 3 | -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | function default( struct rc ) { 3 | param name="rc.name" default="anonymous"; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/subsystems/4hellocontroller/index.cfm -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |
3 | #body# 4 |
5 |
6 | -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/layouts/main.cfm: -------------------------------------------------------------------------------- 1 |
#body#
2 | -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/layouts/main/default.cfm: -------------------------------------------------------------------------------- 1 |

Welcome to FW/1!

2 | #body# 3 | -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Hello #rc.name#!

3 |

Go away!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/4hellocontroller/views/main/other.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Goodbye #rc.name#!

3 |

Come back!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends=framework.one { 2 | } 3 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | property greetingService; 3 | function default( struct rc ) { 4 | param name="rc.name" default="anonymous"; 5 | rc.name = variables.greetingService.greet( rc.name ); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/subsystems/5helloservice/index.cfm -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |
3 | #body# 4 |
5 |
6 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/layouts/main.cfm: -------------------------------------------------------------------------------- 1 |
#body#
2 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/layouts/main/default.cfm: -------------------------------------------------------------------------------- 1 |

Welcome to FW/1!

2 | #body# 3 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/model/services/greeting.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | function greet( string name ) { 3 | return "so-called " & name; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Hello #rc.name#!

3 |

Go away!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/5helloservice/views/main/other.cfm: -------------------------------------------------------------------------------- 1 | 2 |

Goodbye #rc.name#!

3 |

Come back!

4 |
5 | -------------------------------------------------------------------------------- /examples/subsystems/errortest/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | variables.framework.diLocations = "services"; 4 | 5 | } 6 | -------------------------------------------------------------------------------- /examples/subsystems/errortest/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property mainService; 4 | 5 | function init( fw ) { 6 | variables.fw = fw; 7 | } 8 | 9 | function before( rc ) { 10 | if ( !structKeyExists( rc, "beforeCalls" ) ) rc.beforeCalls = [ ]; 11 | arrayAppend( rc.beforeCalls, request.action ); 12 | } 13 | 14 | function default( rc ) { 15 | rc.data = variables.mainService.default( 42 ); 16 | } 17 | 18 | function error( rc ) { 19 | rc.data = variables.mainService.error(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/subsystems/errortest/index.cfm: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /examples/subsystems/errortest/services/main.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function error() { 4 | return "services/main.cfc:error() was called"; 5 | } 6 | 7 | function default( foo ) { 8 | // cause an exception by referencing undefined variable bar: 9 | return foo + bar; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /examples/subsystems/errortest/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | I won't display because the service contains an error. -------------------------------------------------------------------------------- /examples/subsystems/errortest/views/main/error.cfm: -------------------------------------------------------------------------------- 1 | 

An Error Occurred

2 |

I am the application error view: main.error (in errortest).

3 |

Details of the exception:

4 | 5 |
    6 |
  • Failed action: 7 | 8 | 9 | #replace( request.failedAction, "<", "<", "all" )# 10 | 11 | unknown 12 | 13 |
  • 14 |
  • Application event: #request.event#
  • 15 |
  • Exception type: #request.exception.type#
  • 16 |
  • Exception message: #request.exception.message#
  • 17 |
  • Exception detail: #request.exception.detail#
  • 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /examples/todos/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | this.name = "todoapp"; 4 | 5 | variables.framework = { 6 | unhandledExtensions = "cfc,map,css,js,html", 7 | unhandledPaths = "/fonts", 8 | generateSES = 'true', 9 | routes = [ //Just for fun..... 10 | { "$GET/todo/:id" = "/main/get/id/:id" }, 11 | { "$GET/todo" = "/main/list/" }, 12 | { "$DELETE/todo/:id" = "/main/delete/id/:id" }, 13 | { "$POST/todo/" = "/main/save" } 14 | ] 15 | }; 16 | 17 | function setupApplication() { 18 | 19 | } 20 | 21 | function setupRequest() { 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /examples/todos/assets/todo.json: -------------------------------------------------------------------------------- 1 | {"6":{"status":"Complete","title":"Feed the cat"},"2":{"status":"Pending","title":"Clean the toilet"},"8":{"status":"Pending","title":"Vote in the elections"},"9":{"status":"New","title":"Test the new todos app"}} 2 | -------------------------------------------------------------------------------- /examples/todos/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /examples/todos/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /examples/todos/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /examples/todos/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component accessors = true { 2 | 3 | property framework; 4 | property todoservice; 5 | 6 | public void function default( struct rc ) { 7 | 8 | location(url:"index.html",addtoken:false); 9 | 10 | } 11 | 12 | public void function get( struct rc ) { 13 | 14 | var todobean = todoservice.get(arguments.rc.id); 15 | 16 | framework.renderdata("JSON" , todobean); 17 | 18 | } 19 | 20 | public void function delete( struct rc ) { 21 | 22 | var ret = todoservice.delete(arguments.rc.id); 23 | 24 | framework.renderdata("JSON" , ret); 25 | 26 | } 27 | 28 | public void function list( struct rc ) { 29 | 30 | var todos = todoservice.list(); 31 | 32 | framework.renderdata("JSON" , todos); 33 | 34 | } 35 | 36 | public void function save( struct rc ) { 37 | 38 | var ret = todoservice.save( arguments.rc ); 39 | 40 | framework.renderdata("JSON" , ret); 41 | 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /examples/todos/index.cfm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-icons_228ef1_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-icons_228ef1_256x240.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-icons_ef8c08_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-icons_ef8c08_256x240.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-icons_ffd27a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-icons_ffd27a_256x240.png -------------------------------------------------------------------------------- /examples/todos/jquery/css/ui-lightness/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/todos/jquery/css/ui-lightness/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /examples/todos/model/services/todo.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | public any function init( ) { 4 | 5 | variables.todoFile = expandPath( "/examples/todos/assets/todo.json" ) ; 6 | variables.todos = deserializeJSON(fileRead( variables.todoFile ) ); 7 | 8 | } 9 | 10 | public any function list( ) { 11 | 12 | var ret = structCopy(variables.todos); 13 | ret['keylist'] = structKeyArray(todos) ; 14 | arraySort( ret['keylist'] ,"numeric" , "desc"); 15 | 16 | return todos ; 17 | 18 | } 19 | 20 | public any function get( string id ) { 21 | 22 | if ( structKeyExists( todos , arguments.id) ) { 23 | return todos[arguments.id]; 24 | } 25 | else return 0; 26 | 27 | 28 | } 29 | 30 | public any function save( struct data ) { 31 | 32 | 33 | param name="data.id" default=0; 34 | param name="data.title" default="No Title Provided" ; 35 | param name="data.status" default="New" ; 36 | 37 | todos[ data.id ]["title"] = data["title"] ; 38 | todos[ data.id ]["status"] = data["status"] ; 39 | 40 | FileWrite( todoFile, serializeJson(todos) ); 41 | 42 | return todos; 43 | 44 | } 45 | 46 | public any function delete( required string id ) { 47 | 48 | structDelete(todos , id); 49 | FileWrite( todoFile, serializeJson(todos) ); 50 | 51 | return todos; 52 | 53 | } 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /examples/userManager/Application.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | // copy this to your application root to use as your Application.cfc 3 | // or incorporate the logic below into your existing Application.cfc 4 | 5 | // you can provide a specific application name if you want: 6 | //this.name = hash( getBaseTemplatePath() ); 7 | this.name = 'fw1-userManager'; 8 | 9 | // any other application settings: 10 | this.sessionManagement = true; 11 | 12 | // set up per-application mappings as needed: 13 | this.mappings[ '/framework' ] = expandPath( '../../framework' ); 14 | this.mappings[ '/userManager' ] = getDirectoryFromPath( getCurrentTemplatePath() ); 15 | 16 | function _get_framework_one() { 17 | if ( !structKeyExists( request, '_framework_one' ) ) { 18 | 19 | // create your FW/1 application: 20 | request._framework_one = new MyApplication(); 21 | 22 | // you can specify FW/1 configuration as an argument: 23 | // request._framework_one = new framework.one({ 24 | // base : '/app', 25 | // trace : true 26 | // }); 27 | 28 | // if you need to override extension points, use 29 | // MyApplication.cfc for those and then do: 30 | // request._framework_one = new MyApplication({ 31 | // base : '/app', 32 | // trace : true 33 | // }); 34 | 35 | } 36 | return request._framework_one; 37 | } 38 | 39 | // delegation of lifecycle methods to FW/1: 40 | function onApplicationStart() { 41 | return _get_framework_one().onApplicationStart(); 42 | } 43 | function onError( exception, event ) { 44 | return _get_framework_one().onError( exception, event ); 45 | } 46 | function onRequest( targetPath ) { 47 | return _get_framework_one().onRequest( targetPath ); 48 | } 49 | function onRequestEnd() { 50 | return _get_framework_one().onRequestEnd(); 51 | } 52 | function onRequestStart( targetPath ) { 53 | return _get_framework_one().onRequestStart( targetPath ); 54 | } 55 | function onSessionStart() { 56 | return _get_framework_one().onSessionStart(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /examples/userManager/MyApplication.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | // FW/1 - configuration: 4 | variables.framework = { 5 | home = "user.default", 6 | trace = true 7 | }; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/userManager/controllers/user.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property departmentService; 4 | property userService; 5 | 6 | function init( fw ) { 7 | variables.fw = fw; 8 | } 9 | 10 | function default( rc ) { 11 | rc.message = "Welcome to the Framework One User Manager application demo!"; 12 | } 13 | 14 | function delete( rc ) { 15 | variables.userService.delete( rc.id ); 16 | variables.fw.frameworkTrace( "deleted user", rc.id ); 17 | variables.fw.redirect( "user.list" ); 18 | } 19 | 20 | function form( rc ) { 21 | rc.user = variables.userService.get( argumentCollection = rc ); 22 | rc.departments = variables.departmentService.list(); 23 | } 24 | 25 | function get( rc ) { 26 | rc.data = variables.userService.get( rc.id ); 27 | } 28 | 29 | function list( rc ) { 30 | rc.data = variables.userService.list(); 31 | } 32 | 33 | function save( rc ) { 34 | var user = getUserService().get( argumentCollection = rc ); 35 | variables.fw.populate( cfc = user, trim = true ); 36 | if ( structKeyExists( rc, "departmentId" ) && len( rc.departmentId ) ) { 37 | user.setDepartmentId( rc.departmentId ); 38 | user.setDepartment( variables.departmentService.get( rc.departmentId ) ); 39 | } 40 | variables.userService.save( user ); 41 | variables.fw.frameworkTrace( "added user", user ); 42 | variables.fw.redirect( "user.list" ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /examples/userManager/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/userManager/index.cfm -------------------------------------------------------------------------------- /examples/userManager/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | User Manager 5 | 6 | 7 | 8 | 9 |
10 | 11 |

User Manager

12 | 13 | 19 | 20 |
21 | 22 |
23 | #body# 24 |
25 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /examples/userManager/model/beans/department.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property id; 4 | property name; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /examples/userManager/model/beans/user.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property id; 4 | property firstName; 5 | property lastName; 6 | property email; 7 | property departmentId; 8 | property department; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /examples/userManager/model/services/department.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | variables.departments = { }; 4 | 5 | function init( any beanFactory ) { 6 | 7 | variables.beanFactory = beanFactory; 8 | var dept = ""; 9 | 10 | // since services are cached department data we'll be persisted 11 | // ideally, this would be saved elsewhere, e.g. database 12 | 13 | // FIRST 14 | dept = variables.beanFactory.getBean( "departmentBean" ); 15 | dept.setId("1"); 16 | dept.setName("Accounting"); 17 | 18 | variables.departments[dept.getId()] = dept; 19 | 20 | // SECOND 21 | dept = variables.beanFactory.getBean( "departmentBean" ); 22 | dept.setId("2"); 23 | dept.setName("Sales"); 24 | 25 | variables.departments[dept.getId()] = dept; 26 | 27 | // THIRD 28 | dept = variables.beanFactory.getBean( "departmentBean" ); 29 | dept.setId("3"); 30 | dept.setName("Support"); 31 | 32 | variables.departments[dept.getId()] = dept; 33 | 34 | // FOURTH 35 | dept = variables.beanFactory.getBean( "departmentBean" ); 36 | dept.setId("4"); 37 | dept.setName("Development"); 38 | 39 | variables.departments[dept.getId()] = dept; 40 | 41 | return this; 42 | } 43 | 44 | function get( id ) { 45 | var result = ""; 46 | if ( len( id ) && structKeyExists( variables.departments, id ) ) { 47 | result = variables.departments[ id ]; 48 | } else { 49 | result = variables.beanFactory.getBean( "departmentBean" ); 50 | } 51 | return result; 52 | } 53 | 54 | function list() { 55 | return variables.departments; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /examples/userManager/views/user/default.cfm: -------------------------------------------------------------------------------- 1 |

#rc.message#

2 | 3 | 4 |

The framework cache (and application scope) have been reset.

5 |
-------------------------------------------------------------------------------- /examples/userManager/views/user/form.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

User Info

5 | 6 | 7 |
8 | 9 | 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 41 |
42 | 43 |
44 | 45 |
46 | 47 |
48 |
-------------------------------------------------------------------------------- /examples/userManager/views/user/list.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
IdNameEmailDepartmentDelete
No users exist but new ones can be added.
#local.id##local.user.getFirstName()# #local.user.getLastName()##local.user.getEmail()##local.user.getDepartment().getName()#DELETE
33 |
-------------------------------------------------------------------------------- /examples/userManagerAJAX/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | this.mappings["/userManagerAJAX"] = getDirectoryFromPath(getCurrentTemplatePath()); 4 | this.name = 'fw1-userManagerAJAX'; 5 | 6 | // FW/1 - configuration: 7 | variables.framework = { 8 | home = "user.default" 9 | }; 10 | 11 | function setupRequest() { 12 | controller( 'user.checkAjaxRequest' ); 13 | } 14 | 15 | function redirect( string action, string preserve = "none", string append = "none", 16 | string path = variables.framework.baseURL, string queryString = "" ) { 17 | if ( append != "all" ) { 18 | if ( append == "none" ) { 19 | append = ""; 20 | } 21 | append = listAppend( append, "isAjaxRequest" ); 22 | } 23 | super.redirect( argumentCollection = arguments ); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /examples/userManagerAJAX/controllers/user.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property departmentService; 4 | property userService; 5 | 6 | function init( fw ) { 7 | variables.fw = fw; 8 | return this; 9 | } 10 | 11 | function default( rc ) { 12 | rc.message = "Welcome to the Framework One User Manager demo!"; 13 | } 14 | 15 | function delete( rc ) { 16 | variables.userService.delete( rc.id ); 17 | variables.fw.redirect( "user.list" ); 18 | } 19 | 20 | function form( rc ) { 21 | param name="rc.id" default="0"; 22 | rc.user = variables.userService.get( rc.id ); 23 | rc.departments = variables.departmentService.list(); 24 | } 25 | 26 | function list( rc ) { 27 | rc.data = variables.userService.list(); 28 | } 29 | 30 | function save( rc ) { 31 | param name="rc.id" default="0"; 32 | var user = variables.userService.get( rc.id ); 33 | variables.fw.populate( cfc = user, trim = true ); 34 | if ( structKeyExists( rc, "departmentId" ) && len( rc.departmentId ) ) { 35 | user.setDepartmentId( rc.departmentId ); 36 | user.setDepartment( variables.departmentService.get( rc.departmentId ) ); 37 | } 38 | rc.data = variables.userService.save( user ); 39 | variables.fw.redirect( "user.list" ); 40 | } 41 | 42 | function checkAjaxRequest( rc ) { 43 | var httpData = getHttpRequestData(); 44 | if ( structKeyExists( rc, "isAjaxRequest" ) && isBoolean( rc.isAjaxRequest ) ) { 45 | return; 46 | } 47 | rc.isAjaxRequest = structKeyExists( httpData, "headers" ) && 48 | structKeyExists( httpData.headers, "X-Requested-With" ) && 49 | httpData.headers[ "X-Requested-With" ] == "XMLHttpRequest"; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /examples/userManagerAJAX/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/userManagerAJAX/index.cfm -------------------------------------------------------------------------------- /examples/userManagerAJAX/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | User Manager 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 |

User Manager

15 | 16 | 22 | 23 |
24 | 25 |
26 | #body# 27 |
28 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /examples/userManagerAJAX/layouts/user.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | #body# -------------------------------------------------------------------------------- /examples/userManagerAJAX/model/beans/department.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property id; 4 | property name; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /examples/userManagerAJAX/model/beans/user.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property id; 4 | property firstName; 5 | property lastName; 6 | property email; 7 | property departmentId; 8 | property department; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /examples/userManagerAJAX/model/services/department.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | variables.departments = { }; 4 | 5 | function init( beanFactory ) { 6 | variables.beanFactory = beanFactory; 7 | var dept = ""; 8 | 9 | // since services are cached department data we'll be persisted 10 | // ideally, this would be saved elsewhere, e.g. database 11 | 12 | // FIRST 13 | dept = beanFactory.getBean("departmentBean"); 14 | dept.setId("1"); 15 | dept.setName("Accounting"); 16 | 17 | variables.departments[dept.getId()] = dept; 18 | 19 | // SECOND 20 | dept = beanFactory.getBean("departmentBean"); 21 | dept.setId("2"); 22 | dept.setName("Sales"); 23 | 24 | variables.departments[dept.getId()] = dept; 25 | 26 | // THIRD 27 | dept = beanFactory.getBean("departmentBean"); 28 | dept.setId("3"); 29 | dept.setName("Support"); 30 | 31 | variables.departments[dept.getId()] = dept; 32 | 33 | // FOURTH 34 | dept = beanFactory.getBean("departmentBean"); 35 | dept.setId("4"); 36 | dept.setName("Development"); 37 | 38 | variables.departments[dept.getId()] = dept; 39 | return this; 40 | } 41 | 42 | function get(id) { 43 | var result = ""; 44 | 45 | if ( len(id) && structKeyExists(variables.departments, id) ) { 46 | result = variables.departments[id]; 47 | } else { 48 | result = variables.beanFactory.getBean("departmentBean"); 49 | } 50 | 51 | return result; 52 | } 53 | 54 | function list() { 55 | return variables.departments; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /examples/userManagerAJAX/views/user/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

The framework cache (and application scope) have been reset.

5 | 6 |
7 | 8 |

#rc.message#

9 | 10 |

This version of the User Manager demo is powered by jQuery to 11 | demonstrate an accessible application that isn't dependent on JavaScript. 12 | If JavaScript is disabled the application will function as a normal 13 | multi-page app, meaning click a link it loads a whole new page. Although 14 | if JavaScript is enabled the application works as a single page app 15 | (the default intended behavior) where the page doesn't refresh and any 16 | new content loaded is added dynamically to the DOM. All reusing the same 17 | views and just disabling layouts on any AJAX calls.

-------------------------------------------------------------------------------- /examples/userManagerAJAX/views/user/form.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

User Info

5 | 6 | 7 |
8 | 9 | 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 41 |
42 | 43 |
44 | 45 |
46 | 47 |
48 |
-------------------------------------------------------------------------------- /examples/userManagerAJAX/views/user/list.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
IdNameEmailDepartmentDelete
No users exist but new ones can be added.
#local.id##local.user.getFirstName()# #local.user.getLastName()##local.user.getEmail()##local.user.getDepartment().getName()#DELETE
33 |
-------------------------------------------------------------------------------- /examples/userManagerAccessControl/Application.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true extends="framework.one" { 2 | 3 | property departmentService; 4 | 5 | this.mappings["/userManager"] = getDirectoryFromPath(getCurrentTemplatePath()); 6 | this.name = 'fw1-userManager-accessControl-5'; 7 | this.sessionmanagement = true; 8 | this.sessiontimeout = createTimeSpan(0,2,0,0); 9 | 10 | // FW/1 - configuration: 11 | variables.framework = { 12 | trace = true 13 | }; 14 | 15 | function setupApplication() { 16 | application.adminEmail = 'admin@mysite.com'; 17 | if ( variables.keyExists( "departmentService" ) ) 18 | writeDump( var = variables.departmentService, label = "setupApplication" ); 19 | } 20 | 21 | function setupSession() { 22 | controller( 'security.session' ); 23 | if ( variables.keyExists( "departmentService" ) ) 24 | writeDump( var = variables.departmentService, label = "setupSession" ); 25 | } 26 | 27 | function setupRequest() { 28 | controller( 'security.authorize' ); 29 | if ( variables.keyExists( "departmentService" ) ) 30 | writeDump( var = variables.departmentService, label = "setupRequest" ); 31 | } 32 | 33 | function setupView( rc ) { 34 | if ( variables.keyExists( "departmentService" ) ) { 35 | writeDump( var = variables.departmentService, label = "setupView" ); 36 | rc.d1 = departmentService.get( 1 ); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/assets/config/Application.cfm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/assets/config/beans.xml.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 67 | 68 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/controllers/login.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property userService; 4 | 5 | function init( fw ) { 6 | variables.fw = fw; 7 | return this; 8 | } 9 | 10 | function before( rc ) { 11 | if ( structKeyExists( session, "auth" ) && session.auth.isLoggedIn && 12 | variables.fw.getItem() != "logout" ) { 13 | variables.fw.redirect( "main" ); 14 | } 15 | } 16 | 17 | function login( rc ) { 18 | // if the form variables do not exist, redirect to the login form 19 | if ( !structKeyExists( rc, "email" ) || !structKeyExists( rc, "password" ) ) { 20 | variables.fw.redirect( "login" ); 21 | } 22 | // look up the user's record by the email address 23 | var user = variables.userService.getByEmail( rc.email ); 24 | // if that's a real user, verify their password is also correct 25 | var userValid = user.getId() ? variables.userService.validatePassword( user, rc.password ) : false; 26 | // on invalid credentials, redisplay the login form 27 | if ( !userValid ) { 28 | rc.message = ["Invalid Username or Password"]; 29 | variables.fw.redirect( "login", "message" ); 30 | } 31 | // set session variables from valid user 32 | session.auth.isLoggedIn = true; 33 | session.auth.fullname = user.getFirstName() & " " & user.getLastName(); 34 | session.auth.user = user; 35 | 36 | variables.fw.redirect( "main" ); 37 | } 38 | 39 | function logout( rc ) { 40 | // reset session variables 41 | session.auth.isLoggedIn = false; 42 | session.auth.fullname = "Guest"; 43 | structdelete( session.auth, "user" ); 44 | rc.message = ["You have safely logged out"]; 45 | variables.fw.redirect( "login", "message" ); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property userService; 4 | 5 | function init( fw ) { 6 | variables.fw = fw; 7 | } 8 | 9 | function password( rc ) { 10 | rc.id = session.auth.user.getId(); 11 | } 12 | 13 | function change( rc ) { 14 | rc.user = variables.userService.get( rc.id ); 15 | rc.message = variables.userService.checkPassword( argumentCollection = rc ); 16 | if ( !arrayIsEmpty( rc.message ) ) { 17 | variables.fw.redirect( "main.password", "message" ); 18 | } 19 | var newPasswordHash = variables.userService.hashPassword( rc.newPassword ); 20 | rc.passwordHash = newPasswordHash.hash; 21 | rc.passwordSalt = newPasswordHash.salt; 22 | // this will update any user fields from RC so it's a bit overkill here 23 | variables.fw.populate( cfc = rc.user, trim = true ); 24 | 25 | variables.userService.save( rc.user ); 26 | rc.message = ["Your password was changed"]; 27 | variables.fw.redirect( "main", "message" ); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/controllers/security.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init( fw ) { 4 | variables.fw = fw; 5 | } 6 | 7 | function session( rc ) { 8 | // set up the user's session 9 | session.auth = {}; 10 | session.auth.isLoggedIn = false; 11 | session.auth.fullname = 'Guest'; 12 | } 13 | 14 | function authorize( rc ) { 15 | // check to make sure the user is logged on 16 | if ( not ( structKeyExists( session, "auth" ) && session.auth.isLoggedIn ) && 17 | !listfindnocase( 'login', variables.fw.getSection() ) && 18 | !listfindnocase( 'main.error', variables.fw.getFullyQualifiedAction() ) ) { 19 | variables.fw.redirect('login'); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/userManagerAccessControl/index.cfm -------------------------------------------------------------------------------- /examples/userManagerAccessControl/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | function aaa() { } 4 | function bbb() { } 5 | 6 | 7 | 8 | 9 | 10 | User Manager with Access Control 11 | 12 | 13 | 14 | 15 |
16 | 17 |

User Manager with Access Control

18 | 19 | 33 | 34 |
35 | 36 |
37 | 38 | 39 | 40 | 41 |

#msg#

42 |
43 |
44 | 45 | #body# 46 |
47 |
48 | 49 |
50 | 51 | 52 | 53 |

aaa and bbb are equal -- WTF?

54 | 55 |

aaa and bbb are different -- as expected!

56 |
57 | 58 |

I haz a sad -- functions cannot be compared!

59 | 60 |
61 |
62 | 63 | 64 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/model/beans/department.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property id; 4 | property name; 5 | 6 | function init( string id = 0, string name = "" ) { 7 | variables.id = id; 8 | variables.name = name; 9 | return this; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/model/beans/role.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property id; 4 | property name; 5 | 6 | function init( string id = 0, string name = "" ) { 7 | variables.id = id; 8 | variables.name = name; 9 | return this; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/model/beans/user.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property id; 4 | property firstname; 5 | property lastname; 6 | property email; 7 | property department; 8 | property departmentid; 9 | property role; 10 | property roleid; 11 | property passwordHash; 12 | property passwordSalt; 13 | 14 | function init( string id = 0, string firstname = "", string lastname = "", string email = "", 15 | any department = "", any role = "", string passwordHash = "", string passwordSalt = "" ) { 16 | variables.id = id; 17 | variables.firstname = firstname; 18 | variables.lastname = lastname; 19 | variables.email = email; 20 | variables.department = department; 21 | if ( isObject( department ) ) { 22 | variables.departmentid = department.getId(); 23 | } else { 24 | variables.departmentid = ""; 25 | } 26 | variables.role = role; 27 | if ( isObject( role ) ) { 28 | variables.roleid = role.getId(); 29 | } else { 30 | variables.roleid = 2; // default role id is user 31 | } 32 | variables.passwordHash = passwordHash; 33 | variables.passwordSalt = passwordSalt; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/model/services/department.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init( any beanFactory ) { 4 | variables.beanFactory = beanFactory; 5 | variables.departments = { }; 6 | 7 | // since services are cached department data will be persisted 8 | // ideally, this would be saved elsewhere, e.g. database 9 | 10 | // FIRST 11 | var dept = variables.beanFactory.getBean("departmentBean"); 12 | dept.setId("1"); 13 | dept.setName("Accounting"); 14 | 15 | variables.departments[dept.getId()] = dept; 16 | 17 | // SECOND 18 | dept = variables.beanFactory.getBean("departmentBean"); 19 | dept.setId("2"); 20 | dept.setName("Sales"); 21 | 22 | variables.departments[dept.getId()] = dept; 23 | 24 | // THIRD 25 | dept = variables.beanFactory.getBean("departmentBean"); 26 | dept.setId("3"); 27 | dept.setName("Support"); 28 | 29 | variables.departments[dept.getId()] = dept; 30 | 31 | // FOURTH 32 | dept = variables.beanFactory.getBean("departmentBean"); 33 | dept.setId("4"); 34 | dept.setName("Development"); 35 | 36 | variables.departments[dept.getId()] = dept; 37 | 38 | return this; 39 | } 40 | 41 | function get( string id ) { 42 | var result = 0; 43 | if ( len( id ) && structKeyExists( variables.departments, id ) ) { 44 | result = variables.departments[ id ]; 45 | } else { 46 | result = variables.beanFactory.getBean("departmentBean"); 47 | } 48 | return result; 49 | } 50 | 51 | function list() { 52 | return variables.departments; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/model/services/role.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init( beanFactory ) { 4 | variables.beanFactory = beanFactory; 5 | variables.roles = { }; 6 | 7 | // since services are cached role data will be persisted 8 | // ideally, this would be saved elsewhere, e.g. database 9 | 10 | // FIRST 11 | var role = variables.beanFactory.getBean("roleBean"); 12 | role.setId("1"); 13 | role.setName("Admin"); 14 | 15 | variables.roles[role.getId()] = role; 16 | 17 | // SECOND 18 | role = variables.beanFactory.getBean("roleBean"); 19 | role.setId("2"); 20 | role.setName("User"); 21 | 22 | variables.roles[role.getId()] = role; 23 | 24 | return this; 25 | } 26 | 27 | function get( string id ) { 28 | var result = 0; 29 | if ( len( id ) && structKeyExists( variables.roles, id ) ) { 30 | result = variables.roles[ id ]; 31 | } else { 32 | result = variables.beanFactory.getBean( "roleBean" ); 33 | } 34 | return result; 35 | } 36 | 37 | function list() { 38 | return variables.roles; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/views/login/default.cfm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Login
16 | 17 |
18 |
19 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/views/main/default.cfm: -------------------------------------------------------------------------------- 1 |  2 |

The framework cache (and application scope) have been reset.

3 |
4 | 5 |

Welcome, #session.auth.fullname#

-------------------------------------------------------------------------------- /examples/userManagerAccessControl/views/main/password.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Change Password
21 | 22 |
23 | 24 |

Your New Password:

25 |
    26 |
  • Can not match your current password
  • 27 |
  • Must be at least 8 characters long
  • 28 |
  • Must contain at least 1 letter
  • 29 |
  • Must contain at least 1 number or special character
  • 30 |
  • Is case sensitive
  • 31 |
  • Can not contain your email address
  • 32 |
33 |
34 | -------------------------------------------------------------------------------- /examples/userManagerAccessControl/views/user/default.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/userManagerAccessControl/views/user/default.cfm -------------------------------------------------------------------------------- /examples/userManagerAccessControl/views/user/list.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
IdNameEmailDepartmentDelete
No users exist but new ones can be added.
#local.id##local.user.getFirstName()# #local.user.getLastName()##local.user.getEmail()##local.user.getDepartment().getName()#DELETE
33 |
-------------------------------------------------------------------------------- /examples/views/main/default.cfm: -------------------------------------------------------------------------------- 1 |

Welcome to the Framework One examples - with subsystems!

2 |

This shows how individual FW/1 applications can be reused as 3 | subsystems in a larger application with no code changes!

4 |

Examples

5 | 6 | 14 | 15 | -------------------------------------------------------------------------------- /examples/views/main/error.cfm: -------------------------------------------------------------------------------- 1 | 

An Error Occurred

2 |

I am the subsystem error view: home:main.error.

3 |

Details of the exception:

4 | 5 |
    6 |
  • Failed action: 7 | 8 | 9 | #replace( request.failedAction, "<", "<", "all" )# 10 | 11 | unknown 12 | 13 |
  • 14 |
  • Application event: #request.event#
  • 15 |
  • Exception type: #request.exception.type#
  • 16 |
  • Exception message: #request.exception.message#
  • 17 |
  • Exception detail: #request.exception.detail#
  • 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /examples/wirebox/Application.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | variables.framework = { 4 | diEngine = "wirebox", 5 | diLocations = "examples.wirebox.model" 6 | }; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /examples/wirebox/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property friendlyservice; 4 | 5 | function default( rc ) { 6 | rc.message = variables.friendlyservice.greeting(); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/wirebox/index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/examples/wirebox/index.cfm -------------------------------------------------------------------------------- /examples/wirebox/model/friendlyservice.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function greeting() { 4 | return "Hello from Wirebox-provided, FW/1-autowired friendly service!"; 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /examples/wirebox/views/main/default.cfm: -------------------------------------------------------------------------------- 1 |

WireBox is our bean factory!

2 |

#rc.message#

3 | -------------------------------------------------------------------------------- /framework/Application.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | // Version: FW/1 4.3.0 3 | 4 | // copy this to your application root to use as your Application.cfc 5 | // or incorporate the logic below into your existing Application.cfc 6 | 7 | // you can provide a specific application name if you want: 8 | this.name = hash( getBaseTemplatePath() ); 9 | 10 | // any other application settings: 11 | this.sessionManagement = true; 12 | 13 | // set up per-application mappings as needed: 14 | // this.mappings[ '/framework' ] = expandPath( '../path/to/framework' ); 15 | // this.mappings[ '/app' ] expandPath( '../path/to/app' ); 16 | 17 | function _get_framework_one() { 18 | if ( !structKeyExists( request, '_framework_one' ) ) { 19 | 20 | // create your FW/1 application: 21 | request._framework_one = new framework.one(); 22 | 23 | // you can specify FW/1 configuration as an argument: 24 | // request._framework_one = new framework.one({ 25 | // base : '/app', 26 | // trace : true 27 | // }); 28 | 29 | // if you need to override extension points, use 30 | // MyApplication.cfc for those and then do: 31 | // request._framework_one = new MyApplication({ 32 | // base : '/app', 33 | // trace : true 34 | // }); 35 | 36 | } 37 | return request._framework_one; 38 | } 39 | 40 | // delegation of lifecycle methods to FW/1: 41 | function onApplicationStart() { 42 | return _get_framework_one().onApplicationStart(); 43 | } 44 | function onError( exception, event ) { 45 | return _get_framework_one().onError( exception, event ); 46 | } 47 | function onRequest( targetPath ) { 48 | return _get_framework_one().onRequest( targetPath ); 49 | } 50 | function onRequestEnd() { 51 | return _get_framework_one().onRequestEnd(); 52 | } 53 | function onRequestStart( targetPath ) { 54 | return _get_framework_one().onRequestStart( targetPath ); 55 | } 56 | function onSessionStart() { 57 | return _get_framework_one().onSessionStart(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /framework/MyApplication.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | // Version: FW/1 4.3.0-SNAPSHOT 3 | 4 | // if you need to provide extension points, copy this to 5 | // your web root, next to your Application.cfc, and add 6 | // functions to it, then in Application.cfc use: 7 | // request._framework_one = new MyApplication( config ); 8 | // instead of: 9 | // request._framework_one = new framework.one( config ); 10 | // in the _get_framework_one() function. 11 | // 12 | // if you do not need extension points, you can ignore this 13 | 14 | function setupApplication() { } 15 | 16 | function setupEnvironment( env ) { } 17 | 18 | function setupSession() { } 19 | 20 | function setupRequest() { } 21 | 22 | function setupResponse( rc ) { } 23 | 24 | function setupSubsystem( module ) { } 25 | 26 | function setupView( rc ) { } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /framework/WireBoxAdapter.cfc: -------------------------------------------------------------------------------- 1 | component extends="wirebox.system.ioc.Injector" { 2 | variables._fw1_version = "4.3.0"; 3 | /* 4 | Copyright (c) 2010-2018, Sean Corfield 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // the FW/1 requirements for a bean factory are very simple: 20 | 21 | public boolean function containsBean( string beanName ) { 22 | return super.containsInstance( beanName ); 23 | } 24 | 25 | public any function getBean( string beanName, struct constructorArgs ) { 26 | if ( structKeyExists( arguments, "constructorArgs" ) ) { 27 | return super.getInstance( name=beanName, initArguments=constructorArgs ); 28 | } 29 | return super.getInstance( beanName ); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /framework/facade.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | variables._fw1_version = "4.3.0"; 3 | /* 4 | Copyright (c) 2016-2018, Sean Corfield 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | function init() { 20 | try { 21 | return request._fw1.theFramework; 22 | } catch ( any e ) { 23 | throw( 24 | type = "FW1.FacadeException", message = "Unable to locate FW/1 for this request", 25 | detail = "It appears that you asked for the facade in a request that did not originate in FW/1?" 26 | ); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /framework/methodProxy.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | variables._fw1_version = "4.3.0"; 3 | /* 4 | Copyright (c) 2018, Sean Corfield 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | function init( fw, method ) { 20 | variables.fw = fw; 21 | variables.method = method; 22 | return this; 23 | } 24 | 25 | // implements Java 8 Function interface 26 | function apply( arg ) { 27 | return invoke( variables.fw, method, [ arg ] ); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /framework/nullObject.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | function onMissingMethod( string missingMethodName, struct missingMethodArguments ) { 3 | return this; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /index.cfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1/d7fb9add9b82be4d7c884ebb2d0f88ffb59ed8c9/index.cfm -------------------------------------------------------------------------------- /introduction/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | public void function default( struct rc ) { 4 | rc.files = directoryList( expandPath(request.base) & "../examples/", false, "query" ); 5 | rc.subsystems = directoryList( expandPath(request.base) & "../examples/subsystems/", false, "query" ); 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /introduction/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | FW/1 - Framework One 7 | " /> 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | #body# 16 |
17 |
18 | FW/1 is copyright (c) 2009-#year( now() )# Sean Corfield, Marcin Szczepanski, Ryan Cogswell - 19 | Licensed under the Apache License, Version 2.0
20 | You are running FW/1 version #variables.framework.version# on #server.coldfusion.productname & " " & 21 | ( structKeyExists( server, "lucee" ) ? 22 | server.lucee.version & " / " : "" ) & 23 | server.coldfusion.productversion#. 24 |
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /introduction/views/about/default.cfm: -------------------------------------------------------------------------------- 1 |
2 |
3 |

FW/1 - Framework One - leverages Application.cfc and some simple conventions to provide a 'full' MVC framework in a single file.

4 |

Intended to require near-zero configuration, FW/1 lets you build your application without worrying about a framework getting in your way.

5 |

Controllers, Services (the gateway to your application's model), Views and Layouts are all 'discovered' using straightforward conventions.

6 |

Your controller and service CFCs don't need to extend anything.

7 |

Your views and layouts don't need to know about objects and method calls (a simple 'request context' structure - rc - is available containing URL and form scope data as well as data setup and passed by the framework and controllers).

8 |

Supports your choice of bean factory (as long as it offers containsBean(name) and getBean(name) methods) and autowiring of controllers and services. Your controller and service CFC instances can be managed by your bean factory instead if you prefer, again following a simple naming convention!

9 |
10 |
11 | -------------------------------------------------------------------------------- /introduction/views/main/default.cfm: -------------------------------------------------------------------------------- 1 |

Welcome to Framework One!

2 | #view('about/default')# 3 |

Documentation

4 |

Read the documentation for FW/1. 5 | The latest news can always be found on the FW/1 blog 6 | which also has links to the FW/1 mailing list 7 | and other avenues for community support.

8 |

Examples

9 | #view('main/examples')# 10 | -------------------------------------------------------------------------------- /introduction/views/main/examples.cfm: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
  • 4 | #rc.subsystems.name# 5 |
  • 6 |
    7 | 8 | 9 | 12 |
  • 13 | #rc.files.name# 14 | 15 | 16 | - requires Java 8! 17 | 18 | 19 | - will not work with a non-empty context root! 20 | 21 | 22 | - requires /examples/todos/index.cfm/* as a wildcard pattern for Tomcat! 23 | 24 | 25 |
  • 26 |
    27 |
    28 |
  • Examples as subsystems - reuses some of the examples "as-is".
  • 29 |
30 | -------------------------------------------------------------------------------- /introduction/views/main/missingview.cfm: -------------------------------------------------------------------------------- 1 | I'm sorry, but no such view is available! 2 | 3 | -------------------------------------------------------------------------------- /server.json: -------------------------------------------------------------------------------- 1 | { 2 | "app":{ 3 | "cfengine":"lucee@5" 4 | }, 5 | "web":{ 6 | "http":{ 7 | "port":"8500" 8 | } 9 | }, 10 | "openbrowser":"false" 11 | } -------------------------------------------------------------------------------- /skeleton/controllers/main.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property beanFactory; 4 | property formatterService; 5 | 6 | public any function init( fw ) { 7 | variables.fw = fw; 8 | return this; 9 | } 10 | 11 | public void function default( rc ) { 12 | var instant = variables.beanFactory.getBean( "instant" ); 13 | rc.today = variables.formatterService.longdate( instant.created() ); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /skeleton/index.cfm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /skeleton/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FW/1 Skeleton - <cfoutput>#rc.title#</cfoutput> 5 | 6 | 7 |

FW/1 Default Layout

8 | #body# 9 |

10 | Powered by FW/1 version #variables.framework.version#.
11 | This request took #getTickCount() - rc.startTime#ms. 12 |

13 | 14 | -------------------------------------------------------------------------------- /skeleton/model/beans/instant.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init() { 4 | variables.when = now(); 5 | } 6 | 7 | function created() { 8 | return variables.when; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /skeleton/model/services/formatter.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | public string function longdate( any when ) { 4 | return dateFormat( when, 'long' ) & " at " & timeFormat( when, 'long' ); 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /skeleton/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | 2 |

This is the default view for FW/1.

3 | 4 |

This page was rendered on #rc.today#.

-------------------------------------------------------------------------------- /skeleton/views/main/error.cfm: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 |

ERROR!

5 |
6 |

An error occurred!

7 | 8 | 9 | 10 | Action: #replace( request.failedAction, "<", "<", "all" )#
11 | 12 | Action: unknown
13 |
14 | Error: #request.exception.cause.message#
15 | Type: #request.exception.cause.type#
16 | Details: #request.exception.cause.detail#
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /tests/AddBeanTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | variables.added = 5 | new framework.ioc( "" ) 6 | .declare( "known" ).asValue( 42 ).done(); 7 | } 8 | 9 | function testHaveKnownValue() { 10 | assertEquals( 42, variables.added.getBean( "known" ) ); 11 | } 12 | 13 | function testBeSingleton() { 14 | assertTrue( variables.added.isSingleton( "known" ) ); 15 | } 16 | 17 | function testHaveKnownMetadata() { 18 | var info = variables.added.getBeanInfo( "known" ); 19 | assertEquals( 42, info.value ); 20 | assertTrue( info.isSingleton ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Application.cfc: -------------------------------------------------------------------------------- 1 | component{ 2 | this.name = 'fw1 test'; 3 | variables.here = getDirectoryFromPath(getCurrentTemplatePath()); 4 | this.mappings['/mxunit'] = variables.here & "../testbox/system/compat"; 5 | this.mappings['/framework'] = variables.here & "../framework"; 6 | this.mappings['/tests'] = variables.here; 7 | this.mappings['/goldfish/trumpets'] = variables.here & "extrabeans"; 8 | } 9 | -------------------------------------------------------------------------------- /tests/BasicBeanTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | 4 | function TestNoInterceptors(){ 5 | request.callstack = []; 6 | bf = new framework.aop('/tests/aop/services', {}); 7 | rs = bf.getBean("ReverseService"); 8 | 9 | //Basic Bean Tests 10 | result = rs.doReverse("Hello!"); 11 | AssertEquals("!olleH", result); 12 | AssertEquals(ArrayLen(request.callstack), 1); 13 | AssertEquals(ArrayToList(request.callstack),"doReverse"); 14 | } 15 | 16 | 17 | function TestBeforeInterceptors(){ 18 | 19 | //BeforeAdvice Tests 20 | request.callstack = []; //reset 21 | bf = new framework.aop('/tests/aop/services,/tests/aop/interceptors', {}); 22 | //add an Interceptor 23 | bf.intercept("ReverseService", "BeforeInterceptor"); 24 | rs = bf.getBean("ReverseService"); 25 | 26 | result = rs.doReverse("Hello!"); 27 | 28 | AssertEquals(reverse("beforeHello!"), result, "Before Works"); 29 | AssertEquals(2, arrayLen(request.callstack)); 30 | AssertEquals("before,doReverse", arrayToList(request.callstack)); 31 | } 32 | 33 | 34 | function TestAfterInterceptors(){ 35 | //AfterAdvice Tests 36 | request.callstack = []; //reset 37 | bf = new framework.aop('/tests/aop/services,/tests/aop/interceptors', {}); 38 | 39 | //add an Interceptor 40 | bf.intercept("ReverseService", "AfterInterceptor"); 41 | 42 | rs = bf.getBean("ReverseService"); 43 | 44 | result = rs.doReverse("Hello!"); 45 | 46 | AssertEquals(reverse("Hello!"), result, "Reverse still Works"); 47 | AssertEquals(2, ArrayLen(request.callstack)); 48 | AssertEquals("doReverse,after", ArrayToList(request.callstack)); 49 | } 50 | 51 | 52 | function TestAroundInterceptors(){ 53 | //AroundAdvice Tests 54 | request.callstack = []; //reset 55 | bf = new framework.aop('/tests/aop/services,/tests/aop/interceptors', {}); 56 | //add an Interceptor 57 | bf.intercept("ReverseService", "AroundInterceptor"); 58 | rs = bf.getBean("ReverseService"); 59 | 60 | result = rs.doReverse("Hello!"); 61 | 62 | AssertEquals("around," & reverse("Hello!") & ",around", result, "Called method through Around"); 63 | AssertEquals(arrayLen(request.callstack), 2); 64 | AssertEquals("around,doReverse", arrayToList(request.callstack)); 65 | } 66 | } -------------------------------------------------------------------------------- /tests/CircularTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function testResolveCircular() { 4 | var bf = new framework.ioc( "/tests/circular" ); 5 | var a = bf.getBean( "a" ); 6 | var b = bf.getBean( "b" ); 7 | a.getVariables = getVariables; 8 | b.getVariables = getVariables; 9 | assertTrue( structKeyExists( a.getVariables(), "b" ) ); 10 | assertTrue( structKeyExists( b.getVariables(), "a" ) ); 11 | assertEquals( a.id, b.getVariables().a.id ); 12 | assertEquals( b.id, a.getVariables().b.id ); 13 | assertFalse( structKeyExists( a, "name" ) ); 14 | assertFalse( structKeyExists( b, "name" ) ); 15 | } 16 | 17 | function testResolveAndConfigureCircular() { 18 | var bf = new framework.ioc( "/tests/circular", { initMethod = "configure" } ); 19 | var a = bf.getBean( "a" ); 20 | var b = bf.getBean( "b" ); 21 | a.getVariables = getVariables; 22 | b.getVariables = getVariables; 23 | assertTrue( structKeyExists( a.getVariables(), "b" ) ); 24 | assertTrue( structKeyExists( b.getVariables(), "a" ) ); 25 | assertEquals( a.id, b.getVariables().a.id ); 26 | assertEquals( b.id, a.getVariables().b.id ); 27 | assertEquals( "A", a.name ); 28 | assertEquals( "B", b.name ); 29 | } 30 | 31 | private function getVariables() { 32 | return variables; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /tests/ConstantTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | variables.constants = new framework.ioc( "", { constants = { known = 42 } } ); 5 | } 6 | 7 | function testHaveKnownValue() { 8 | assertEquals( 42, variables.constants.getBean( "known" ) ); 9 | } 10 | 11 | function testBeSingleton() { 12 | assertTrue( variables.constants.isSingleton( "known" ) ); 13 | } 14 | 15 | function testHaveKnownMetadata() { 16 | var info = variables.constants.getBeanInfo( "known" ); 17 | assertEquals( 42, info.value ); 18 | assertTrue( info.isSingleton ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/DisableLayoutTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="tests.InjectableTest" { 2 | 3 | public void function setUp() { 4 | clearFrameworkFromRequest(); 5 | variables.fw = new framework.one(); 6 | variables.fwvars = getVariablesScope( variables.fw ); 7 | variables.fwvars.framework = { 8 | base = "/tests/layout" 9 | }; 10 | } 11 | 12 | function testEnabledLayout() { 13 | var output = ""; 14 | variables.fw.onRequestStart( "" ); 15 | savecontent variable="output" { 16 | variables.fw.onRequest( "" ); 17 | } 18 | //writedump(output);abort; 19 | assertEquals( trim( output ), "[layout]VIEW[/layout]" ); 20 | } 21 | 22 | function testExplicitlyEnabledLayout() { 23 | variables.fw.enableLayout(); 24 | var output = ""; 25 | variables.fw.onRequestStart( "" ); 26 | savecontent variable="output" { 27 | variables.fw.onRequest( "" ); 28 | } 29 | //writedump(output);abort; 30 | assertEquals( trim( output ), "[layout]VIEW[/layout]" ); 31 | } 32 | 33 | 34 | function testDisabledLayout() { 35 | variables.fw.disableLayout(); 36 | var output = ""; 37 | variables.fw.onRequestStart( "" ); 38 | savecontent variable="output" { 39 | variables.fw.onRequest( "" ); 40 | } 41 | assertEquals( trim( output ), "VIEW" ); 42 | } 43 | 44 | function testReEnabledLayout() { 45 | variables.fw.disableLayout(); 46 | variables.fw.enableLayout(); 47 | var output = ""; 48 | variables.fw.onRequestStart( "" ); 49 | savecontent variable="output" { 50 | variables.fw.onRequest( "" ); 51 | } 52 | assertEquals( trim( output ), "[layout]VIEW[/layout]" ); 53 | } 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /tests/EmptyTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | variables.emptyFactory = new framework.ioc( "" ); 5 | } 6 | 7 | function testContainBeanFactory() { 8 | assertTrue( variables.emptyFactory.containsBean( "beanFactory" ) ); 9 | } 10 | 11 | function testContainJustOneBean() { 12 | var info = variables.emptyFactory.getBeanInfo(); 13 | assertEquals( 1, structCount( info.beaninfo ) ); 14 | assertEquals( "beanfactory", structKeyList( info.beaninfo ) ); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tests/ExtraBeansTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function testResolveMapping() { 4 | var factory = new framework.ioc( "/tests/extrabeans" ); 5 | application.itemCount = 0; 6 | assertTrue( factory.containsBean( "item" ) ); 7 | assertTrue( factory.containsBean( "itemSheep" ) ); 8 | var item1 = factory.getBean( "item" ); 9 | var item2 = factory.getBean( "itemSheep" ); 10 | // since sheep was not specified as singular, item should 11 | // be a singleton and itemSheep should be an alias to it 12 | assertSame( item1, item2 ); 13 | assertEquals( 1, application.itemCount ); 14 | } 15 | 16 | function testResolveMappingWithSingular() { 17 | var factory = new framework.ioc( "/tests/extrabeans", 18 | { singulars = { sheep = "bean" } } ); 19 | application.itemCount = 0; 20 | assertTrue( factory.containsBean( "item" ) ); 21 | assertTrue( factory.containsBean( "itemBean" ) ); 22 | var item1 = factory.getBean( "item" ); 23 | var item2 = factory.getBean( "itemBean" ); 24 | // since sheep was mapped to bean as a singular it should 25 | // be a transient and those items should be unique 26 | assertNotSame( item1, item2 ); 27 | assertEquals( 2, application.itemCount ); 28 | } 29 | 30 | function testNotInjectTypedProperty() { 31 | structDelete( application, "itemCount" ); 32 | variables.factory = new framework.ioc( "/tests/model, /tests/extrabeans", 33 | { singulars = { sheep = "lamb" }, 34 | omitTypedProperties = true } ); 35 | assertTrue( variables.factory.containsBean( "item" ) ); 36 | assertTrue( variables.factory.isSingleton( "item" ) ); 37 | assertTrue( variables.factory.containsBean( "itemLamb" ) ); 38 | assertTrue( variables.factory.isSingleton( "itemLamb" ) ); 39 | var user = variables.factory.getBean( "user" ); 40 | var item = user.itemTest(); 41 | assertFalse( isSimpleValue( item ) ); 42 | assertEquals( 1, application.itemCount ); 43 | var lamb = user.getItemLamb(); 44 | assertTrue( isNull( lamb ) ); 45 | assertEquals( 1, application.itemCount ); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /tests/FactoryBeanTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function testSupportBasicFactoryMethod() { 4 | var bf = new framework.ioc( "/tests/model" ); 5 | bf.declare( "a" ).fromFactory( "factory", "makeMeAnA" ); 6 | assertEquals( "I am an A", bf.getBean( "a" ) ); 7 | } 8 | 9 | function testSupportFactoryFunction() { 10 | var bf = new framework.ioc( "/tests/model" ); 11 | bf.declare( "a" ).fromFactory( function() { 12 | return "I am an A"; 13 | } ); 14 | assertEquals( "I am an A", bf.getBean( "a" ) ); 15 | } 16 | 17 | function testSupportFactoryMethodViaBean() { 18 | var bf = new framework.ioc( "" ); 19 | var factory = new tests.model.services.factory(); 20 | bf.factoryBean( "a", factory, "makeMeAnA" ); 21 | assertEquals( "I am an A", bf.getBean( "a" ) ); 22 | } 23 | 24 | function testSupportFactoryMethodWithBeanArg() { 25 | var bf = new framework.ioc( "/tests/model" ); 26 | bf.declare( "a" ) 27 | .fromFactory( "factory", "makeAWithFava" ) 28 | .withArguments( [ "favaBean" ] ); 29 | assertEquals( "I am a fava bean", bf.getBean( "a" ) ); 30 | } 31 | 32 | function testSupportFactoryMethodWithLocalArg() { 33 | var bf = new framework.ioc( "/tests/model" ); 34 | bf.declare( "a" ) 35 | .fromFactory( "factory", "makeAWithFava" ) 36 | .withArguments( [ "favaBean" ] ) 37 | .withOverrides( { favaBean = { stamp = "different" } } ); 38 | assertEquals( "I am a different bean", bf.getBean( "a" ) ); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /tests/InitMethodWithConstantsTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | 5 | var constantInstance = new initMethod.Constant(); 6 | var constants = { known = 42, booleanValue = true, constObj = constantInstance }; 7 | 8 | variables.beanFactory = new framework.ioc( "/tests/initMethod", { constants = constants , initMethod = "configure"} ); 9 | 10 | } 11 | 12 | function testHaveCalledConfigure () { 13 | var myService = beanFactory.getBean("myService"); 14 | assertEquals( 42, myService.getResult()); 15 | } 16 | 17 | function testNotConfigureConstants () { 18 | var constObj = beanFactory.getBean("constObj"); 19 | 20 | assertFalse( constObj.getBooleanValue() ); 21 | assertFalse( constObj.hasConfigureBeenCalled() ); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /tests/InjectPropertiesTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | variables.ioc = new framework.ioc( "" ); 5 | variables.ioc2 = new framework.ioc( "/tests/model" ); 6 | } 7 | 8 | function testInjectWithType() { 9 | var bean = ioc.injectProperties( "tests.declared.things.myconfig", { name = "ByType" } ); 10 | assertEquals( "ByType", bean.getName() ); 11 | try { 12 | var data = bean.getConfig(); 13 | fail( "constructor should not have been called" ); 14 | } catch ( any e ) { 15 | assertEquals( "expression", e.type ); 16 | } 17 | } 18 | 19 | function testInjectWithObject() { 20 | var bean = ioc.injectProperties( 21 | new declared.things.myconfig( "object" ), 22 | { name = "ByObject" } ); 23 | assertEquals( "ByObject", bean.getName() ); 24 | assertEquals( "object", bean.getConfig() ); 25 | } 26 | 27 | function testInjectWithName() { 28 | variables.ioc 29 | .addBean( "data", "data" ) 30 | .declareBean( "configObject", "tests.declared.things.myconfig" ); 31 | var bean = variables.ioc.injectProperties( "configObject", { name = "ByName" } ); 32 | assertEquals( "ByName", bean.getName() ); 33 | assertEquals( "data", bean.getConfig() ); 34 | } 35 | 36 | function testInjectWithNullValues( numeric userid, string username ) { 37 | // use arguments to pass into bean, argument values are null 38 | var bean = variables.ioc2.injectProperties( "user2Bean", arguments ); 39 | assertEquals( "0", bean.getUserid() ); 40 | assertEquals( "defaultuser", bean.getUsername() ); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /tests/InjectableTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | private any function clearFrameworkFromRequest () { 4 | structDelete(request, "_fw1"); 5 | structDelete(request, "layout"); 6 | } 7 | 8 | private any function getVariablesScope( any cfc ) { 9 | cfc.__$$fetchVariables = returnVariablesScope; 10 | var vars = cfc.__$$fetchVariables(); 11 | structDelete( cfc, "__$$fetchVariables" ); 12 | return vars; 13 | } 14 | 15 | private any function returnVariablesScope() { 16 | return variables; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tests/MappingTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function testResolveMapping() { 4 | var factory = new framework.ioc( "/goldfish/trumpets" ); 5 | application.itemCount = 0; 6 | assertTrue( factory.containsBean( "item" ) ); 7 | assertTrue( factory.containsBean( "itemSheep" ) ); 8 | var item1 = factory.getBean( "item" ); 9 | var item2 = factory.getBean( "itemSheep" ); 10 | // since sheep was not specified as singular, item should 11 | // be a singleton and itemSheep should be an alias to it 12 | assertSame( item1, item2 ); 13 | assertEquals( 1, application.itemCount ); 14 | } 15 | 16 | function testResolveMappingWithSingular() { 17 | var factory = new framework.ioc( "/goldfish/trumpets", 18 | { singulars = { sheep = "bean" } } ); 19 | application.itemCount = 0; 20 | assertTrue( factory.containsBean( "item" ) ); 21 | assertTrue( factory.containsBean( "itemBean" ) ); 22 | var item1 = factory.getBean( "item" ); 23 | var item2 = factory.getBean( "itemBean" ); 24 | // since sheep was mapped to bean as a singular it should 25 | // be a transient and those items should be unique 26 | assertNotSame( item1, item2 ); 27 | assertEquals( 2, application.itemCount ); 28 | } 29 | 30 | /* 31 | function testAcceptExpandedPath() { 32 | // on CI, webroot does not match current directory so this becomes 33 | // an undeducible path... 34 | var servicePath = expandPath( "/tests/services" ); 35 | var factory = new framework.ioc( servicePath ); 36 | assertTrue( factory.containsBean( "user" ) ); 37 | assertTrue( factory.containsBean( "userService" ) ); 38 | var svc1 = factory.getBean( "user" ); 39 | var svc2 = factory.getBean( "userService" ); 40 | assertSame( svc1, svc2 ); 41 | } 42 | */ 43 | 44 | function testAcceptRelativePath() { 45 | var servicePath = "/tests/services"; 46 | var factory = new framework.ioc( servicePath ); 47 | assertTrue( factory.containsBean( "user" ) ); 48 | assertTrue( factory.containsBean( "userService" ) ); 49 | var svc1 = factory.getBean( "user" ); 50 | var svc2 = factory.getBean( "userService" ); 51 | assertSame( svc1, svc2 ); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /tests/ModelServiceTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | application.userServiceCount = 0; 5 | variables.factory = new framework.ioc( "/tests/model, /tests/services", { transients = [ "fish" ] } ); 6 | } 7 | 8 | function testHaveUserFishAndUserService() { 9 | assertTrue( variables.factory.containsBean( "userFish" ) ); 10 | assertTrue( variables.factory.containsBean( "userService" ) ); 11 | assertFalse( variables.factory.containsBean( "user" ) ); 12 | var user1 = variables.factory.getBean( "userFish" ); 13 | var user2 = variables.factory.getBean( "userFish" ); 14 | assertNotSame( user1, user2 ); 15 | } 16 | 17 | function testInjectUserServiceIntoProduct() { 18 | assertEquals( 0, application.userServiceCount ); 19 | var svc1 = variables.factory.getBean( "userService" ); 20 | assertEquals( 1, application.userServiceCount ); 21 | var svc2 = variables.factory.getBean( "userService" ); 22 | assertEquals( 1, application.userServiceCount ); 23 | var svc3 = variables.factory.getBean( "product" ); 24 | assertSame( svc1, svc2 ); 25 | assertEquals( 1, svc1.getId() ); 26 | assertEquals( 1, svc2.getId() ); 27 | assertEquals( 1, svc3.getUserService().getId() ); 28 | assertSame( svc1, svc3.getUserService() ); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /tests/ModelTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | variables.factory = new framework.ioc( "/tests/model", { transients = [ "fish" ] } ); 5 | } 6 | 7 | function testHaveBeanServiceButNoShortForm() { 8 | assertTrue( variables.factory.containsBean( "favaBean" ) ); 9 | assertTrue( variables.factory.containsBean( "favaService" ) ); 10 | assertFalse( variables.factory.containsBean( "fava" ) ); 11 | } 12 | 13 | function testHaveProductAndProductService() { 14 | assertTrue( variables.factory.containsBean( "productService" ) ); 15 | assertTrue( variables.factory.containsBean( "product" ) ); 16 | var svc1 = variables.factory.getBean( "productService" ); 17 | var svc2 = variables.factory.getBean( "product" ); 18 | assertSame( svc1, svc2 ); 19 | } 20 | 21 | function testHavePintoAndPintoBean() { 22 | assertTrue( variables.factory.containsBean( "pintoBean" ) ); 23 | assertTrue( variables.factory.containsBean( "pinto" ) ); 24 | var bean1 = variables.factory.getBean( "pintoBean" ); 25 | var bean2 = variables.factory.getBean( "pinto" ); 26 | assertNotSame( bean1, bean2 ); 27 | } 28 | 29 | function testHaveUserAndUserFish() { 30 | assertTrue( variables.factory.containsBean( "userFish" ) ); 31 | assertTrue( variables.factory.containsBean( "user" ) ); 32 | var user1 = variables.factory.getBean( "userFish" ); 33 | var user2 = variables.factory.getBean( "user" ); 34 | assertNotSame( user1, user2 ); 35 | // but product (service) is injected 36 | assertSame( user1.getProduct(), user2.getProduct() ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /tests/ParentTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | variables.parent = new framework.ioc( "", { constants = { one = 1, two = 2 } } ); 5 | variables.factory = new framework.ioc( "", { constants = { one = "I", three = "III" } } ); 6 | variables.factory.setParent( variables.parent ); 7 | } 8 | 9 | function testFindInParent() { 10 | assertEquals( 2, variables.factory.getBean( "two" ) ); 11 | } 12 | 13 | function testFindInChild() { 14 | assertEquals( "I", variables.factory.getBean( "one" ) ); 15 | assertEquals( "III", variables.factory.getBean( "three" ) ); 16 | } 17 | 18 | function testContainViaParent() { 19 | assertTrue( variables.factory.containsBean( "two" ) ); 20 | } 21 | 22 | function testGetMetadataViaParent() { 23 | var info = variables.factory.getBeanInfo( "two" ); 24 | assertEquals( 2, info.value ); 25 | assertTrue( info.isSingleton ); 26 | } 27 | 28 | function testBeSingletonViaParent() { 29 | assertTrue( variables.factory.isSingleton( "two" ) ); 30 | } 31 | 32 | function testHaveParentInMetadata() { 33 | var info = variables.factory.getBeanInfo(); 34 | assertTrue( structKeyExists( info, "parent" ) ); 35 | assertEquals( variables.parent.getBeanInfo(), info.parent ); 36 | } 37 | 38 | function testNotHaveParentWithRegex() { 39 | var info = variables.factory.getBeanInfo( regex = "X" ); 40 | assertFalse( structKeyExists( info, "parent" ) ); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /tests/aop/interceptors/BasicInterceptor.cfc.test: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @author @markdrew 4 | * @description This is a demo interceptor 5 | * 6 | */ 7 | component output="false" displayname="BasicInterceptor" { 8 | 9 | this.name = "A"; 10 | 11 | public function init(name="A"){ 12 | this.name = name; 13 | return this; 14 | } 15 | 16 | 17 | //basically it's onMissingMethod! 18 | function before(method, args, target){ 19 | param name="request.callstack" default="#[]#"; 20 | 21 | arguments.args.1 = "before" & arguments.args.1 22 | } 23 | 24 | function after(){ 25 | param name="request.callstack" default="#[]#"; 26 | arguments.result = arguments.result & "after"; 27 | 28 | } 29 | 30 | function onMethod(){ 31 | param name="request.callstack" default="#[]#"; 32 | dump(var=arguments, label="onMethod"); 33 | } 34 | 35 | function onError(){ 36 | param name="request.callstack" default="#[]#"; 37 | dump(var=arguments, label="onError"); 38 | } 39 | } -------------------------------------------------------------------------------- /tests/aop/interceptors/aop/AfterInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="AfterInterceptor" extends="interceptor" accessors="true" output="false" { 2 | 3 | 4 | function init(name="after") { 5 | this.name=name; 6 | } 7 | 8 | 9 | function after(target, method, args, result) { 10 | getStackLogService().log(this.name); 11 | 12 | // Demonstrate that we can alter the result. 13 | if (findNoCase("alter", this.name) && structKeyExists(arguments, "result") && !isNull(arguments.result)) 14 | { 15 | return arguments.result & "," & this.name; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /tests/aop/interceptors/aop/AroundInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="AroundInterceptor" extends="interceptor" accessors="true" output="false" { 2 | 3 | 4 | function init(name="around") { 5 | this.name=name; 6 | } 7 | 8 | 9 | function around(target, method, args) { 10 | getStackLogService().log(this.name); 11 | 12 | local.result = proceed(arguments.target, arguments.method, arguments.args); 13 | 14 | // This runs on 'set...' methods as well for properties. Limit to simple result calls. 15 | if (structKeyExists(local, "result") && !isNull(local.result) && isSimpleValue(local.result)) 16 | { 17 | return this.name & "," & local.result & "," & this.name; 18 | } 19 | else 20 | { 21 | writeDump(var = isNull(arguments.target)); 22 | writeDump(var = isNull(arguments.target.getStackLogService())); 23 | writeDump(var = arguments.method); 24 | writeDump(var = structKeyList(arguments.target), abort = true); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /tests/aop/interceptors/aop/BeforeInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="BeforeInterceptor" extends="interceptor" accessors="true" output="false" { 2 | 3 | 4 | function init(name="before") { 5 | this.name=name; 6 | } 7 | 8 | 9 | function before(target, method, args) { 10 | getStackLogService().log(this.name); 11 | 12 | translateArgs(target, method, args, true); 13 | 14 | // Demonstrate that we can alter the arguments before the method call. 15 | if (structKeyExists(arguments.args, "input")) 16 | { 17 | arguments.args.input = "before" & arguments.args.input; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /tests/aop/interceptors/aop/ErrorInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component output="false" { 2 | 3 | this.name = "onError"; 4 | function init(name="onError"){ 5 | this.name=name; 6 | } 7 | 8 | function onError(method,args,target, error){ 9 | ArrayAppend(request.callstack, this.name); 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /tests/aop/interceptors/aop/interceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="interceptor" accessors="true" output="false" { 2 | 3 | 4 | property name="stackLogService"; 5 | 6 | 7 | this.name = ""; 8 | } -------------------------------------------------------------------------------- /tests/aop/interceptors/example/Logger.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init(LogService){ 4 | this.logService = logService; 5 | return this; 6 | } 7 | function before(methodname, args, target){ 8 | this.logService.logMessage("Before:" & arguments.args.input); 9 | 10 | } 11 | function after(result, methodname, args, target){ 12 | this.logService.logMessage("After:" & arguments.result); 13 | } 14 | } -------------------------------------------------------------------------------- /tests/aop/services/Log.cfc: -------------------------------------------------------------------------------- 1 | component{ 2 | 3 | function init(){ 4 | return this; 5 | } 6 | 7 | function logMessage(message, severity="information"){ 8 | writelog(message, severity); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /tests/aop/services/Reverse.cfc: -------------------------------------------------------------------------------- 1 | component displayname="reverseService" extends="stringService" accessors="true" output="false" { 2 | 3 | 4 | public function doForward(string input) { 5 | //I double reverse a string... i.e. do nothing! 6 | getStackLogService().log("doForward"); 7 | return reverse(reverse(arguments.input)); 8 | } 9 | 10 | 11 | public function doReverse(string input) { 12 | getStackLogService().log("doReverse"); 13 | return reverse(arguments.input); 14 | } 15 | 16 | 17 | public function throwError() { 18 | //This is just to throw an error 19 | getStackLogService().log("throwError"); 20 | throw "I AM AN EVIL ERROR YOU WANT TO TRAP!"; 21 | } 22 | } -------------------------------------------------------------------------------- /tests/aop/services/advReverse.cfc: -------------------------------------------------------------------------------- 1 | component displayname="advReverseService" extends="Reverse" accessors="true" output="false" { 2 | 3 | 4 | // PUBLIC METHODS 5 | public function configure() { 6 | getStackLogService().log("configure"); 7 | return this; 8 | } 9 | 10 | 11 | public function doWrap(string input) { 12 | getStackLogService().log("doWrap"); 13 | return doRear(doFront(arguments.input)); 14 | } 15 | 16 | 17 | public function init() { 18 | // stackLogService does not exist at this point. 19 | arrayAppend(request.callStack, "init"); 20 | 21 | return super.init(); 22 | } 23 | 24 | 25 | public function setStackLogService(any stackLogService) { 26 | // stackLogService does not exist at this point. 27 | arrayAppend(request.callStack, "setStackLogService"); 28 | 29 | variables.stackLogService = arguments.stackLogService; 30 | } 31 | 32 | 33 | 34 | 35 | // PRIVATE METHODS 36 | private function doFront(string input) { 37 | getStackLogService().log("doFront"); 38 | return "front-" & arguments.input; 39 | } 40 | 41 | 42 | private function doRear(string input) { 43 | getStackLogService().log("doRear"); 44 | return arguments.input & "-rear"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/aop/services/array.cfc: -------------------------------------------------------------------------------- 1 | component displayname="arrayService" extends="service" accessors="true" output="false" { 2 | 3 | 4 | public array function doListToArray(string list) { 5 | //I double reverse a string... i.e. do nothing! 6 | getStackLogService().log("doListToArray"); 7 | return listToArray(arguments.list); 8 | } 9 | } -------------------------------------------------------------------------------- /tests/aop/services/service.cfc: -------------------------------------------------------------------------------- 1 | component displayname="service" accessors="true" output="false" { 2 | 3 | 4 | property name="stackLogService"; 5 | 6 | 7 | public function getServiceName() { 8 | return listLast(getMetadata(this)); 9 | } 10 | 11 | 12 | public function init() { 13 | return this; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/aop/services/stackLogService.cfc: -------------------------------------------------------------------------------- 1 | component displayname="stackLogService" extends="service" output="false" { 2 | 3 | 4 | public function init() { 5 | if (!structKeyExists(request, "callStack")) 6 | { 7 | request["callStack"] = []; 8 | } 9 | 10 | return super.init(); 11 | } 12 | 13 | 14 | public function log(string message) { 15 | arrayAppend(request.callStack, message); 16 | } 17 | } -------------------------------------------------------------------------------- /tests/aop/services/stringService.cfc: -------------------------------------------------------------------------------- 1 | component displayname="stringService" extends="service" accessors="true" output="false" { 2 | 3 | 4 | property name="stackLogService"; 5 | 6 | 7 | public function init() { 8 | return this; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/circular/a.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property b; 3 | this.id = createUUID(); 4 | function configure() { 5 | this.name = "A"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/circular/b.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property a; 3 | this.id = createUUID(); 4 | function configure() { 5 | this.name = "B"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/coreFunctions.cfc: -------------------------------------------------------------------------------- 1 | component extends=testbox.system.BaseSpec { 2 | 3 | function beforeAll() { 4 | variables.fw = new framework.one(); 5 | variables.fw.__config = __config; 6 | } 7 | 8 | function afterAll() { 9 | } 10 | 11 | function run( testResults, testBox ) { 12 | 13 | describe( "getDefaultSubsystem", function(){ 14 | beforeEach(function(){ 15 | structDelete( request, "subsystem" ); 16 | structDelete( request, "section" ); 17 | structAppend( variables.fw.__config(), { 18 | usingSubsystems : false, 19 | subsystemDelimiter : "@", 20 | defaultSubsystem : "", 21 | defaultSection : "section", 22 | defaultItem : "item" 23 | }); 24 | }); 25 | it( "should return empty string without subsystems", function(){ 26 | expect( fw.getDefaultSubsystem() ).toBeEmpty(); 27 | }); 28 | it( "should return request subsystem, if present", function(){ 29 | fw.__config().usingSubsystems = true; 30 | request.subsystem = "requested"; 31 | expect( fw.getDefaultSubsystem() ).toBe( "requested" ); 32 | }); 33 | it( "should return default subsystem, if request not present", function(){ 34 | fw.__config().usingSubsystems = true; 35 | fw.__config().defaultSubsystem = "subsystem"; 36 | expect( fw.getDefaultSubsystem() ).toBe( "subsystem" ); 37 | }); 38 | it( "should throw an exception, if no default", function(){ 39 | fw.__config().usingSubsystems = true; 40 | expect(function(){ 41 | return fw.getDefaultSubsystem(); 42 | }).toThrow( type = "FW1.subsystemNotSpecified" ); 43 | }); 44 | }); 45 | 46 | } 47 | 48 | function __config() { 49 | return variables.framework; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /tests/declared/things/example.cfc: -------------------------------------------------------------------------------- 1 | component {} -------------------------------------------------------------------------------- /tests/declared/things/myconfig.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | 3 | property string name; 4 | property name="dftname" default="default"; 5 | // not legal syntax: property dftname="default"; 6 | // legal syntax, doesn't create setter: property string dftname="default"; 7 | 8 | function init( string data = "none" ) { 9 | setConfig( data ); 10 | } 11 | 12 | function setConfig( string config ) { 13 | variables.config = config; 14 | } 15 | 16 | function getConfig() { 17 | return variables.config; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tests/defaultPropertyTest.cfc: -------------------------------------------------------------------------------- 1 | component extends=mxunit.framework.TestCase { 2 | 3 | function setup() { 4 | variables.bf = new framework.ioc( "" ) 5 | .declare( "default" ).instanceOf( "tests.extrabeans.sheep.default" ) 6 | .asTransient() 7 | .done(); 8 | } 9 | 10 | function testHaveDefaultValue() { 11 | var data = { 12 | viaNew : new tests.extrabeans.sheep.default(), 13 | viaDI1 : variables.bf.getBean( "default" ) 14 | }; 15 | assertTrue( isNull( data.viaNew.getSimple() ) ); 16 | assertTrue( isNull( data.viaNew.getTyped() ) ); 17 | assertEquals( "Default Value", data.viaNew.getDefaulted() ); 18 | assertEquals( "Default Type Value", data.viaNew.getDefaultedType() ); 19 | assertTrue( isNull( data.viaDI1.getSimple() ) ); 20 | assertTrue( isNull( data.viaDI1.getTyped() ) ); 21 | assertEquals( "Default Value", data.viaDI1.getDefaulted() ); 22 | assertEquals( "Default Type Value", data.viaDI1.getDefaultedType() ); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /tests/extrabeans/sheep/construct.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | property one; 3 | function init(two,item) { 4 | this.two = two; 5 | this.item = item; 6 | return this; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/extrabeans/sheep/default.cfc: -------------------------------------------------------------------------------- 1 | component accessors=true { 2 | property simple; 3 | property name="typed" type="string"; 4 | property name="defaulted" default="Default Value"; 5 | property name="defaultedType" type="string" default="Default Type Value"; 6 | } 7 | -------------------------------------------------------------------------------- /tests/extrabeans/sheep/item.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property beanfactory; 3 | 4 | function init( numeric start = 0 ) { 5 | param name="application.itemCount" default="#start#"; 6 | this.itemNumber = ++application.itemCount; 7 | } 8 | 9 | function getNewItem() { 10 | return variables.beanfactory.getBean( "item" ); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /tests/frameworkErrorTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | public void function setUp() { 4 | variables.fw = new framework.one(); 5 | request._fw1.requestDefaultsInitialized = false; 6 | request.failureCount = 0; 7 | request.outputContent = ""; 8 | injectMethod(variables.fw, this, "exceptionCapture", "dumpException"); 9 | } 10 | 11 | /** 12 | * Test with initialised framework - ensure error handler tries to render the main.error view 13 | */ 14 | public void function testError() 15 | { 16 | var exception = { 17 | type = "Testing", 18 | message = "Testing", 19 | detail = "Detail" 20 | }; 21 | var event = "Test Event"; 22 | variables.fw.onApplicationStart(); 23 | savecontent variable="output" { 24 | variables.fw.onError(exception, event); 25 | }; 26 | assertEquals(request.action, ":main.error"); 27 | assertFalse(output contains "Unable to find a view for ':main.error' action."); 28 | assertTrue(output contains "Unable to find a view for &##x27;&##x3a;main.error&##x27;"); 29 | } 30 | 31 | /** 32 | * Test with un-initialised framework - ensure internal error is not as prominent 33 | */ 34 | public void function testEarlyError() 35 | { 36 | var exception = { 37 | type = "Testing", 38 | message = "Testing", 39 | detail = "Detail" 40 | }; 41 | var event = ""; 42 | savecontent variable="output" { 43 | variables.fw.onError(exception, event); 44 | } 45 | assertFalse(output CONTAINS "Element FRAMEWORK.USINGSUBSYSTEMS is undefined in VARIABLES", "Didn't expect failure in early exception"); 46 | assertTrue(output CONTAINS "Exception occured before FW/1 was initialized", "Expected message about early exception"); 47 | } 48 | 49 | private void function exceptionCapture( any exception) 50 | { 51 | request.capturedException = arguments.exception; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tests/frameworkFacadeTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | structDelete( request, "_fw1" ); // clean up the request 5 | } 6 | 7 | function testFacadeOnNonFW1Request() { 8 | try { 9 | var facade = new framework.facade(); 10 | fail( "facade creation did not fail" ); 11 | } catch ( FW1.FacadeException e ) { 12 | assertEquals( "Unable to locate FW/1 for this request", e.message ); 13 | } catch ( any e ) { 14 | fail( "caught unexpected exception: " & e.message ); 15 | } 16 | } 17 | 18 | function testFacadeWithFW1() { 19 | var fw = new framework.one(); 20 | fw.onRequestStart( "" ); 21 | var facade = new framework.facade(); 22 | assertTrue( structKeyExists( facade, "getBeanFactory" ), "Constructed facade does not look like FW/1" ); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /tests/initMethod/Constant.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property booleanValue; 4 | 5 | function init() { 6 | 7 | setBooleanValue(false); 8 | variables.configureCalled = false; 9 | 10 | return this; 11 | } 12 | 13 | function configure() { 14 | variables.configureCalled = true; 15 | } 16 | 17 | boolean function hasConfigureBeenCalled() { 18 | return variables.configurecalled; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /tests/initMethod/myService.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property known; 4 | property result; 5 | 6 | 7 | function configure() { 8 | setResult(known); 9 | } 10 | 11 | 12 | 13 | } -------------------------------------------------------------------------------- /tests/issue408/ConstructorDependancy.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init( constructorInjectedBean ) { 4 | variables.constructorInjectedBean = constructorInjectedBean; 5 | return this; 6 | } 7 | 8 | function isInjected() { 9 | return structKeyExists( variables, "constructorInjectedBean" ); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/issue408/NoDependancies.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | function init() { 3 | return this; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tests/issue408/SetterDependancy.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | function init() { 3 | return this; 4 | } 5 | 6 | function isInjected() { 7 | return structKeyExists( variables, "SetterInjectedBean" ); 8 | } 9 | 10 | function setSetterInjectedBean( SetterInjectedBean ) { 11 | variables.SetterInjectedBean = SetterInjectedBean; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/issue420/singleton.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property name="beanFactory"; 4 | 5 | function init() { 6 | return this; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/issue420/transient.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property name="singleton"; 4 | 5 | function init() { 6 | return this; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/issue518/Log.cfc: -------------------------------------------------------------------------------- 1 | component{ 2 | 3 | function init(){ 4 | return this; 5 | } 6 | 7 | function logMessage(message, severity="information"){ 8 | writelog(message, severity); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /tests/issue518/daos/advReverse.cfc: -------------------------------------------------------------------------------- 1 | component displayname="advReverseService" extends="tests.issue518.services.Reverse" accessors="true" output="false" { 2 | 3 | 4 | // PUBLIC METHODS 5 | public function configure() { 6 | getStackLog().log("wrong-configure"); 7 | return this; 8 | } 9 | 10 | 11 | public function doWrap(string input) { 12 | getStackLog().log("wrong-doWrap"); 13 | return doRear(doFront(arguments.input)); 14 | } 15 | 16 | 17 | public function init() { 18 | // stackLog does not exist at this point. 19 | arrayAppend(request.callStack, "wrong-init"); 20 | 21 | return super.init(); 22 | } 23 | 24 | 25 | public function setStackLog(any stackLog) { 26 | // stackLog does not exist at this point. 27 | arrayAppend(request.callStack, "wrong-setStackLog"); 28 | 29 | variables.stackLog = arguments.stackLog; 30 | } 31 | 32 | 33 | 34 | 35 | // PRIVATE METHODS 36 | private function doFront(string input) { 37 | getStackLog().log("wrong-doFront"); 38 | return "front-" & arguments.input; 39 | } 40 | 41 | 42 | private function doRear(string input) { 43 | getStackLog().log("wrong-doRear"); 44 | return arguments.input & "-rear"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/issue518/interceptors/BasicInterceptor.cfc.test: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @author @markdrew 4 | * @description This is a demo interceptor 5 | * 6 | */ 7 | component output="false" displayname="BasicInterceptor" { 8 | 9 | this.name = "A"; 10 | 11 | public function init(name="A"){ 12 | this.name = name; 13 | return this; 14 | } 15 | 16 | 17 | //basically it's onMissingMethod! 18 | function before(method, args, target){ 19 | param name="request.callstack" default="#[]#"; 20 | 21 | arguments.args.1 = "before" & arguments.args.1 22 | } 23 | 24 | function after(){ 25 | param name="request.callstack" default="#[]#"; 26 | arguments.result = arguments.result & "after"; 27 | 28 | } 29 | 30 | function onMethod(){ 31 | param name="request.callstack" default="#[]#"; 32 | dump(var=arguments, label="onMethod"); 33 | } 34 | 35 | function onError(){ 36 | param name="request.callstack" default="#[]#"; 37 | dump(var=arguments, label="onError"); 38 | } 39 | } -------------------------------------------------------------------------------- /tests/issue518/interceptors/aop/AfterInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="AfterInterceptor" extends="interceptor" accessors="true" output="false" { 2 | 3 | 4 | function init(name="after") { 5 | this.name=name; 6 | } 7 | 8 | 9 | function after(target, method, args, result) { 10 | getStackLog().log(this.name); 11 | 12 | // Demonstrate that we can alter the result. 13 | if (findNoCase("alter", this.name) && structKeyExists(arguments, "result") && !isNull(arguments.result)) 14 | { 15 | return arguments.result & "," & this.name; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /tests/issue518/interceptors/aop/AroundInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="AroundInterceptor" extends="interceptor" accessors="true" output="false" { 2 | 3 | 4 | function init(name="around") { 5 | this.name=name; 6 | } 7 | 8 | 9 | function around(target, method, args) { 10 | getStackLog().log(this.name); 11 | 12 | local.result = proceed(arguments.target, arguments.method, arguments.args); 13 | 14 | // This runs on 'set...' methods as well for properties. Limit to simple result calls. 15 | if (structKeyExists(local, "result") && !isNull(local.result) && isSimpleValue(local.result)) 16 | { 17 | return this.name & "," & local.result & "," & this.name; 18 | } 19 | else 20 | { 21 | writeDump(var = isNull(arguments.target)); 22 | writeDump(var = isNull(arguments.target.getStackLog())); 23 | writeDump(var = arguments.method); 24 | writeDump(var = structKeyList(arguments.target), abort = true); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/issue518/interceptors/aop/BeforeInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="BeforeInterceptor" extends="interceptor" accessors="true" output="false" { 2 | 3 | 4 | function init(name="before") { 5 | this.name=name; 6 | } 7 | 8 | 9 | function before(target, method, args) { 10 | getStackLog().log(this.name); 11 | 12 | translateArgs(target, method, args, true); 13 | 14 | // Demonstrate that we can alter the arguments before the method call. 15 | if (structKeyExists(arguments.args, "input")) 16 | { 17 | arguments.args.input = "before" & arguments.args.input; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /tests/issue518/interceptors/aop/ErrorInterceptor.cfc: -------------------------------------------------------------------------------- 1 | component output="false" { 2 | 3 | this.name = "onError"; 4 | function init(name="onError"){ 5 | this.name=name; 6 | } 7 | 8 | function onError(method,args,target, error){ 9 | ArrayAppend(request.callstack, this.name); 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /tests/issue518/interceptors/aop/interceptor.cfc: -------------------------------------------------------------------------------- 1 | component displayname="interceptor" accessors="true" output="false" { 2 | 3 | 4 | property name="stackLog"; 5 | 6 | 7 | this.name = ""; 8 | } 9 | -------------------------------------------------------------------------------- /tests/issue518/interceptors/example/Logger.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init(LogService){ 4 | this.logService = logService; 5 | return this; 6 | } 7 | function before(methodname, args, target){ 8 | this.logService.logMessage("Before:" & arguments.args.input); 9 | 10 | } 11 | function after(result, methodname, args, target){ 12 | this.logService.logMessage("After:" & arguments.result); 13 | } 14 | } -------------------------------------------------------------------------------- /tests/issue518/service.cfc: -------------------------------------------------------------------------------- 1 | component displayname="service" accessors="true" output="false" { 2 | 3 | 4 | property name="stackLog"; 5 | 6 | 7 | public function getServiceName() { 8 | return listLast(getMetadata(this)); 9 | } 10 | 11 | 12 | public function init() { 13 | return this; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/issue518/services/Reverse.cfc: -------------------------------------------------------------------------------- 1 | component displayname="reverseService" extends="tests.issue518.string" accessors="true" output="false" { 2 | 3 | 4 | public function doForward(string input) { 5 | //I double reverse a string... i.e. do nothing! 6 | getStackLog().log("doForward"); 7 | return reverse(reverse(arguments.input)); 8 | } 9 | 10 | 11 | public function doReverse(string input) { 12 | getStackLog().log("doReverse"); 13 | return reverse(arguments.input); 14 | } 15 | 16 | 17 | public function throwError() { 18 | //This is just to throw an error 19 | getStackLog().log("throwError"); 20 | throw "I AM AN EVIL ERROR YOU WANT TO TRAP!"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/issue518/services/advReverse.cfc: -------------------------------------------------------------------------------- 1 | component displayname="advReverseService" extends="Reverse" accessors="true" output="false" { 2 | 3 | 4 | // PUBLIC METHODS 5 | public function configure() { 6 | getStackLog().log("configure"); 7 | return this; 8 | } 9 | 10 | 11 | public function doWrap(string input) { 12 | getStackLog().log("doWrap"); 13 | return doRear(doFront(arguments.input)); 14 | } 15 | 16 | 17 | public function init() { 18 | // stackLog does not exist at this point. 19 | arrayAppend(request.callStack, "init"); 20 | 21 | return super.init(); 22 | } 23 | 24 | 25 | public function setStackLog(any stackLog) { 26 | // stackLog does not exist at this point. 27 | arrayAppend(request.callStack, "setStackLog"); 28 | 29 | variables.stackLog = arguments.stackLog; 30 | } 31 | 32 | 33 | 34 | 35 | // PRIVATE METHODS 36 | private function doFront(string input) { 37 | getStackLog().log("doFront"); 38 | return "front-" & arguments.input; 39 | } 40 | 41 | 42 | private function doRear(string input) { 43 | getStackLog().log("doRear"); 44 | return arguments.input & "-rear"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/issue518/services/array.cfc: -------------------------------------------------------------------------------- 1 | component displayname="arrayService" extends="tests.issue518.service" accessors="true" output="false" { 2 | 3 | 4 | public array function doListToArray(string list) { 5 | //I double reverse a string... i.e. do nothing! 6 | getStackLog().log("doListToArray"); 7 | return listToArray(arguments.list); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/issue518/stackLog.cfc: -------------------------------------------------------------------------------- 1 | component displayname="stackLog" extends="service" output="false" { 2 | 3 | 4 | public function init() { 5 | if (!structKeyExists(request, "callStack")) 6 | { 7 | request["callStack"] = []; 8 | } 9 | 10 | return super.init(); 11 | } 12 | 13 | 14 | public function log(string message) { 15 | arrayAppend(request.callStack, message); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/issue518/string.cfc: -------------------------------------------------------------------------------- 1 | component displayname="string" extends="service" accessors="true" output="false" { 2 | 3 | 4 | property name="stackLog"; 5 | 6 | 7 | public function init() { 8 | return this; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/layout/layouts/main/default.cfm: -------------------------------------------------------------------------------- 1 | [layout]#trim(body)#[/layout] 2 | -------------------------------------------------------------------------------- /tests/layout/views/main/default.cfm: -------------------------------------------------------------------------------- 1 | VIEW -------------------------------------------------------------------------------- /tests/model/bases/BaseClass.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property userService; 3 | } 4 | -------------------------------------------------------------------------------- /tests/model/beans/fava.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | this.stamp = "fava"; 3 | } 4 | -------------------------------------------------------------------------------- /tests/model/beans/person.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property name="firstname" default=""; 4 | property name="lastname" default=""; 5 | 6 | function init(){ 7 | return this; 8 | } 9 | } -------------------------------------------------------------------------------- /tests/model/beans/pinto.cfc: -------------------------------------------------------------------------------- 1 | component {} -------------------------------------------------------------------------------- /tests/model/beans/user2Bean.cfc: -------------------------------------------------------------------------------- 1 | component output="false" accessors="true" { 2 | 3 | property username; 4 | property userid; 5 | public any function init( numeric userid = 0, string username = "defaultuser" ) { 6 | setusername( arguments.username ); 7 | setuserid( arguments.userid ); 8 | return this; 9 | } 10 | } -------------------------------------------------------------------------------- /tests/model/beans/user37.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property name="DSN"; 3 | property name="ID"; 4 | public any function init( dsn, ID = 0 ) { 5 | variables.dsn = dsn; 6 | variables.ID = ID; 7 | return this; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/model/beans/user37b.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property name="DSN"; 3 | property name="ID"; 4 | 5 | // to reveal an ordering bug changed ID to cd just so it comes before dsn 6 | public any function init( dsn, cd = 0 ) { 7 | variables.dsn = dsn; 8 | variables.ID = cd; 9 | return this; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/model/beans/user37c.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property name="DSN"; 3 | property name="ID"; 4 | property name="name"; 5 | 6 | public any function init( dsn, ID = 0, NAME = "Bob") { 7 | variables.dsn = dsn; 8 | variables.ID = ID; 9 | variables.name = name; 10 | return this; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/model/fish/user.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | property item; 3 | property string itemLamb; // do not inject this! 4 | 5 | function init( product ) { 6 | variables.product = product; 7 | } 8 | 9 | function getProduct() { 10 | return variables.product; 11 | } 12 | 13 | function itemTest() { 14 | return structKeyExists( variables, "item" ) ? variables.item : "missing"; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tests/model/services/factory.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function makeMeAnA() { 4 | return "I am an A"; 5 | } 6 | 7 | function makeAWithFava( any fava ) { 8 | return "I am a " & fava.stamp & " bean"; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /tests/model/services/fava.cfc: -------------------------------------------------------------------------------- 1 | component {} -------------------------------------------------------------------------------- /tests/model/services/listener.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | 3 | function init() { 4 | variables.loaded = false; 5 | } 6 | 7 | function onLoad( any factory ) { 8 | variables.loaded = true; 9 | } 10 | 11 | function isLoaded() { 12 | return variables.loaded; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /tests/model/services/product.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" extends="tests.model.bases.BaseClass" { 2 | // should inherit userService from BaseClass 3 | } 4 | -------------------------------------------------------------------------------- /tests/omv/layouts/default.cfm: -------------------------------------------------------------------------------- 1 | [#trim(body)#] 2 | -------------------------------------------------------------------------------- /tests/omv/layouts/main/default.cfm: -------------------------------------------------------------------------------- 1 | DEFAULT#body# 2 | -------------------------------------------------------------------------------- /tests/omv/layouts/main/two.cfm: -------------------------------------------------------------------------------- 1 | TWO#body# 2 | -------------------------------------------------------------------------------- /tests/omv/views/main/test.cfm: -------------------------------------------------------------------------------- 1 | TEST 2 | -------------------------------------------------------------------------------- /tests/onSessionStartBuildURLTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="tests.InjectableTest" { 2 | 3 | public void function setUp() { 4 | clearFrameworkFromRequest(); 5 | variables.fw = new framework.one(); 6 | variables.fwvars = getVariablesScope( variables.fw ); 7 | variables.fwvars.framework = { 8 | generateSES = true, 9 | SESOmitIndex = true 10 | }; 11 | } 12 | 13 | public void function testBuildURL() { 14 | // ensure SES URL gets generated in onSessionStart: 15 | variables.fw.setupSession = buildSESURL; 16 | variables.fwvars.setupSession = buildSESURL; 17 | variables.fw.__url = ""; 18 | variables.fw.onSessionStart(); 19 | var expected = "/foo/test/bar/1"; 20 | assertEquals( expected, right( variables.fw.__url, len( expected ) ) ); 21 | } 22 | 23 | private void function buildSESURL() { 24 | this.__url = buildURL( action = "foo.test", queryString = "bar=1" ); 25 | } 26 | 27 | public void function testURLandURI() { 28 | variables.fw.onRequestStart("/index.cfm"); 29 | assertEquals( "useCgiScriptName", variables.fw.getBaseURL() ); 30 | var suffix = "/tests/"; 31 | assertEquals( suffix, 32 | right( variables.fw.buildURL( action = 'main.default' ), len( suffix ) ) ); 33 | suffix &= "main/default"; 34 | assertEquals( suffix, 35 | right( variables.fw.buildCustomURL( uri = '/main/default' ), len( suffix ) ) ); 36 | } 37 | 38 | public void function testURLandURIempty() { 39 | variables.fwvars.framework.baseURL = "/tests/ci/"; 40 | variables.fw.onRequestStart("/index.cfm"); 41 | assertEquals( "/tests/ci", variables.fw.getBaseURL() ); 42 | assertEquals( "/tests/ci", variables.fw.buildURL( action = 'main.default' ) ); 43 | assertEquals( "/tests/ci/main/default", variables.fw.buildCustomURL( uri = '/main/default' ) ); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /tests/runner.cfm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/services/user.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | function init() { 3 | param name="application.userServiceCount" default="0"; 4 | variables.id = ++application.userServiceCount; 5 | } 6 | function getId() { 7 | return variables.id; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/singletonPattern/beans/BarService.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Note that although this beanname matches the singletonpattern it is considered 3 | * a transient as it's in the beans folder 4 | **/ 5 | component accessors="true" { 6 | 7 | property instanceid; 8 | 9 | function init() { 10 | variables.instanceid = CreateUUID(); 11 | return this; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tests/singletonPattern/beans/Beer.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPattern/beans/BeerFactory.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Note that although this beanname matches the singletonpattern it is considered 3 | * a transient as it's in the beans folder 4 | **/ 5 | component accessors="true" { 6 | 7 | property instanceid; 8 | 9 | function init() { 10 | variables.instanceid = CreateUUID(); 11 | return this; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tests/singletonPattern/beans/Wine.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPattern/drink/Coffee.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPattern/drink/DrinksService.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPattern/drink/Tea.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPattern/food/Burger.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPattern/food/FoodFactory.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPattern/food/Pizza.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/singletonPatternTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | /** 5 | * Note that although 'BeerFactory' and 'BarService' match the singletonpattern 6 | * they are considered transients as in the beans folder 7 | **/ 8 | transients = ['BarService','Beer','BeerFactory','Wine','Coffee','Tea','Burger','Pizza']; 9 | singletons = ['DrinksService','FoodFactory']; 10 | 11 | variables.factory = new framework.ioc( "/tests/singletonPattern", { singletonPattern = ".+(Service|Factory)$" } ); 12 | } 13 | 14 | function testForSingletons() { 15 | for ( var s in singletons ) checkForSingletons( s ); 16 | } 17 | function checkForSingletons( required beanname ) dataprovider="singletons" { 18 | assertTrue( variables.factory.containsBean( arguments.beanname ) ); 19 | assertTrue( variables.factory.isSingleton( arguments.beanname ) ); 20 | instanceA = variables.factory.getBean( arguments.beanname ); 21 | instanceB = variables.factory.getBean( arguments.beanname ); 22 | assertSame( instanceA, instanceB ); 23 | } 24 | 25 | function testForTransients() { 26 | for ( var t in transients ) checkForTransients( t ); 27 | } 28 | function checkForTransients( beanname ) dataprovider="transients" { 29 | //assertTrue( variables.factory.containsBean( beanname ) ); 30 | assertFalse( variables.factory.isSingleton( beanname ) ); 31 | instanceA = variables.factory.getBean( arguments.beanname ); 32 | instanceB = variables.factory.getBean( arguments.beanname ); 33 | assertNotSame( instanceA, instanceB ); 34 | } 35 | 36 | function testPatternsAreExclusive() { 37 | try { 38 | var bad = new framework.ioc( '', { singletonPattern = '', transientPattern = '' } ); 39 | fail( 'Both arguments were allowed' ); 40 | } catch ( any e ) { 41 | assertEquals( 'singletonPattern and transientPattern are mutually exclusive', e.message ); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /tests/specs/injectPropertiesTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="testbox.system.BaseSpec" { 2 | // executes before all suites 3 | function beforeAll(){ 4 | ioc = new framework.ioc( "" ); 5 | ioc2 = new framework.ioc( "/tests/model" ); 6 | } 7 | 8 | // executes after all suites 9 | function afterAll(){} 10 | 11 | // All suites go in here 12 | function run( testResults, testBox ){ 13 | describe("A bean injected with properties", function(){ 14 | it("errors on undefined properties in the bean", function(){ 15 | var bean = new tests.model.beans.person(); 16 | 17 | expect( function(){ 18 | ioc.injectProperties( bean=bean, properties= { firstName="steven", thirdName="fail"} ); 19 | }).toThrow(); 20 | }); 21 | 22 | it("does not error on undefined properties in the bean when ignoreMissing is specified", function(){ 23 | var bean = new tests.model.beans.person(); 24 | 25 | ioc.injectProperties( bean=bean, properties= { firstName="steven", thirdName="fail"}, ignoreMissing=true); 26 | expect( bean.getFirstName() ).toBe("steven"); 27 | }); 28 | 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/stubs/Address.cfc: -------------------------------------------------------------------------------- 1 | component accessors = true{ 2 | 3 | property name = line1 getters = true setters = true type = string; 4 | 5 | property name = line2 getters = true setters = true type = string; 6 | 7 | property name = zipCode getters = true setters = true type = string; 8 | 9 | public void function init() 10 | output=false hint="constructor"{ 11 | variables.line1 = ""; 12 | variables.line2 = ""; 13 | variables.zipCode = ""; 14 | } 15 | } -------------------------------------------------------------------------------- /tests/stubs/Contact.cfc: -------------------------------------------------------------------------------- 1 | component accessors = true { 2 | 3 | property name = firstName getters = true setters = true type = string; 4 | property name = lastName getters = true setters = true type = string; 5 | property name = dateCreated getters = true setters = true type = date; 6 | property name = address getters = true setters = true type = stubs.Address; 7 | 8 | public void function init() 9 | output = false hint = "constructor" { 10 | variables.firstName = ""; 11 | variables.lastName = ""; 12 | 13 | variables.Address = new Address(); 14 | //intentionally not initing date created 15 | } 16 | } -------------------------------------------------------------------------------- /tests/stubs/UserOneLevel.cfc: -------------------------------------------------------------------------------- 1 | component accessors = true { 2 | 3 | 4 | property name = username getters = true setters = true type = string; 5 | property name = firstName getters = true setters = true type = string; 6 | property name = lastName getters = true setters = true type = string; 7 | property name = isActive getters = true setters = true type = boolean; 8 | 9 | public void function init() 10 | output = false hint = "constructor" { 11 | variables.username = ""; 12 | variables.firstName = ""; 13 | variables.lastName = ""; 14 | variables.isActive = false; 15 | } 16 | } -------------------------------------------------------------------------------- /tests/stubs/UserThreeLevel.cfc: -------------------------------------------------------------------------------- 1 | component accessors = true { 2 | 3 | property name = username getters = true setters = true type = string; 4 | property name = isActive getters = true setters = true type = boolean; 5 | property name = contact getters = true setters = true type = stubs.Contact; 6 | 7 | 8 | public void function init() 9 | output = false hint = "constructor" { 10 | variables.username = ""; 11 | variables.Contact = new Contact(); 12 | variables.isActive = false; 13 | } 14 | } -------------------------------------------------------------------------------- /tests/stubs/UserTwoLevel.cfc: -------------------------------------------------------------------------------- 1 | component accessors = true { 2 | 3 | property name = username getters = true setters = true type = string; 4 | property name = contact getters = true setters = true type = stubs.Contact; 5 | property name = isActive getters = true setters = true type = boolean; 6 | 7 | 8 | public void function init() 9 | output = false hint = "constructor" { 10 | variables.username = ""; 11 | variables.Contact = new Contact(); 12 | } 13 | } -------------------------------------------------------------------------------- /tests/traceRender/one.cfc: -------------------------------------------------------------------------------- 1 | component extends="framework.one" { 2 | 3 | public void function setupTraceRender( string output = 'html' ) { 4 | if ( output == 'data' ) { 5 | writeOutput( 'custom trace render' ); 6 | } 7 | } 8 | 9 | } -------------------------------------------------------------------------------- /tests/transientPattern/beans/BarService.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Note that although this beanname matches the singletonpattern it is considered 3 | * a transient as it's in the beans folder 4 | **/ 5 | component accessors="true" { 6 | 7 | property instanceid; 8 | 9 | function init() { 10 | variables.instanceid = CreateUUID(); 11 | return this; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tests/transientPattern/beans/Beer.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPattern/beans/BeerFactory.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Note that although this beanname matches the singletonpattern it is considered 3 | * a transient as it's in the beans folder 4 | **/ 5 | component accessors="true" { 6 | 7 | property instanceid; 8 | 9 | function init() { 10 | variables.instanceid = CreateUUID(); 11 | return this; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tests/transientPattern/beans/Wine.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPattern/drink/CoffeeFoo.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPattern/drink/Drinks.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPattern/drink/Tea.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPattern/food/Burger.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPattern/food/FoodFactory.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPattern/food/PizzaFoo.cfc: -------------------------------------------------------------------------------- 1 | component accessors="true" { 2 | 3 | property instanceid; 4 | 5 | function init() { 6 | variables.instanceid = CreateUUID(); 7 | return this; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/transientPatternTest.cfc: -------------------------------------------------------------------------------- 1 | component extends="mxunit.framework.TestCase" { 2 | 3 | function setup() { 4 | transients = ['BarService','Beer','BeerFactory','Wine','CoffeeFoo','PizzaFoo']; 5 | singletons = ['Drinks','Tea','Burger','FoodFactory']; 6 | 7 | variables.factory = new framework.ioc( "/tests/transientPattern", { transientPattern = ".+(Foo)$" } ); 8 | } 9 | 10 | function testForSingletons() { 11 | for ( var s in singletons ) checkForSingletons( s ); 12 | } 13 | function checkForSingletons( required beanname ) dataprovider="singletons" { 14 | assertTrue( variables.factory.containsBean( arguments.beanname ) ); 15 | assertTrue( variables.factory.isSingleton( arguments.beanname ) ); 16 | instanceA = variables.factory.getBean( arguments.beanname ); 17 | instanceB = variables.factory.getBean( arguments.beanname ); 18 | assertSame( instanceA, instanceB ); 19 | } 20 | 21 | function testForTransients() { 22 | for ( var t in transients ) checkForTransients( t ); 23 | } 24 | function checkForTransients( beanname ) dataprovider="transients" { 25 | //assertTrue( variables.factory.containsBean( beanname ) ); 26 | assertFalse( variables.factory.isSingleton( beanname ) ); 27 | instanceA = variables.factory.getBean( arguments.beanname ); 28 | instanceB = variables.factory.getBean( arguments.beanname ); 29 | assertNotSame( instanceA, instanceB ); 30 | } 31 | } 32 | --------------------------------------------------------------------------------