Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
This article illustrates how to create a simple page in sipXconfig, for both user and admin portal.

h1.

...

 Notes

...



Throughout this article I will consider the '/main/sipXconfig' the root directory.

...

Intro

...



h1. Intro

We use test-driven development (TDD)

...

  in order to create / modify a page or fix a issue.

...



TDD is an iterative software development process where you first write the test with the idea that it must fail. See [http://en.wikipedia.org/wiki/Test-driven_development] for more information.

...



For that we use JUnit, JWebUnit, HtmlUnit, DbUnit, etc.

Use 'ant' tool to run these tests (from 'sipXconfig' directory):

ant test-all \-Dtest.name=MyTest

h1. I Admin portal


h2. 1. Add a new menu (MyMenu) and a new entry (MyPage) to the new page   Add a simple page


h3. a. Add a test for the new menu and the new page

Under '/sipXconfig/web/test' directory, create a new package org.sipfoundry.sipxconfig.site.admin.mypackage and a new test class in this package (MyPageTestUi.java):

package org.sipfoundry.sipxconfig.site.admin.mypackage;

public class MyPageTestUi extends WebTestCase {
    public static Test suite() throws Exception {
        return SiteTestHelper.webTestSuite(MyPageTestUi.class);
    }

    @Override
    protected void setUp() throws Exception {
        getTestContext().setBaseUrl(SiteTestHelper.getBaseUrl());
        SiteTestHelper.home(getTester());
        clickLink("toggleNavigation");
        clickLink("menu.myPage");
    }

    public void testDisplay() {
        SiteTestHelper.assertNoException(tester);
        SiteTestHelper.assertNoUserError(tester);
    }
}

Run this test:

ant test-all \-Dtest.name=MyPage

This test will fail with the following errors:

\[junit\]  Test org.sipfoundry.sipxconfig.site.admin.mypackage.MyPageTestUi FAILED

............
\[concat\] testcase: MyPageTestUi
\[concat\] junit.framework.AssertionFailedErrorjunit.framework.AssertionFailedError: Unable to find link with id \[menu.myPage\]

h3. b. Create the menu entry and the page

In sipXconfig/web/context/WEB-INF/common/AdminNavigation.html file, add the next piece of code:


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <li>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<div></div><div></div>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<div>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<a><span key="menu.section.myMenu">My Menu</span></a>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<ul>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<li><a jwcid="@PageLink" id="menu.myPage" page="admin/mypackage/MyPage"><span key="menu.myPage">My Page</span></a></li>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</ul>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</div>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</li>

and in sipXconfig/web/context/WEB-INF/common/AdminNavigation.properties, add the following two lines:

menu.section.myMenu=My Menu
menu.myPage=My Page

Now you can see these changes in the picture below: !1 admin portal menu.JPG|border=1!

Under 'sipXconfig/web/context/WEB-INF/admin/', create 'mypackage' directory and three files in this directory, as follows:

MyPage.page

<?xml version="1.0" encoding="UTF-8"?>
<\!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
&nbsp; "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification>
&nbsp; <description>My page</description>
</page-specification>

MyPage.html

<div jwcid="@common/Border" useDojo="true" borderTitle="ognl:borderTitle">
&nbsp; <span jwcid="@common/QuickHelp" value="message:quick.help" />
&nbsp; <form jwcid="myPageForm@Form" id="myPageForm">
&nbsp; </form>
</div>

MyPage.properties
title=My title page
quick.help=TBD<br/>\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Insert quick help here

Create also /sipXconfig/web/src/org/sipfoundry/sipxconfig/site/user_portal/MyUserPage.java class

package org.sipfoundry.sipxconfig.site.user_portal;

public abstract class MyUserPage extends UserBasePage {

&nbsp;&nbsp;&nbsp; @Override
&nbsp;&nbsp;&nbsp; public void pageBeginRender(PageEvent event) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super.pageBeginRender(event);
&nbsp;&nbsp;&nbsp; }
}

Now MyPageTestUi test will pass  and changes can be seen below: !2 admin portal page.JPG|border=1!

h1. II User portal