Oracle WebCenter Sites 12c的安装与之前的版本有较大不同,加上目前官方的文档还不是很详细,导致很多时候安装不成功。特意写下自己的安装过程,供Tongfu的同事参考。

0.安装所需的软件wcs29

准备好所需软件后,即可开始安装。Oracle数据库与JDK的安装就直接跳下,下面从Weblogic Server的安装开始。

[highlight dark=”no”]1.安装Oracle Weblogic Server 12c[/highlight]

1.1 运行Weblogic Server 安装程序

[highlight dark=”no”]Z:\Oinstall\12C>”c:\Program Files\Java\jdk1.8.0_65\bin\java.exe” -jar fmw_12.2.1.0.0_wls.jar[/highlight]

wcs1

运行下载的jar包,启动weblogic安装程序。

wcs2

 

wcs3

1.2 Auto Updates设置

跳过自动更新设定

wcs4

1.3 选择安装路径

wcs5

1.4 选择安装类型

wcs6

1.5 先决条件检查

wcs7

1.6 跳过安全更新设置

wcs8

1.7 安装选择汇总

页面显示安装选择汇总,点击Install按钮开始安装。

 

wcs9

 

1.8 正式安装Weblogic Server

wcs10

1.9 完成Weblogic Server安装

wcs11

[highlight dark=”no”]2.安装Oracle Fusion Middleware Infrastructure[/highlight]

2.1 运行安装命令,启动Oracle Fusion Middleware Infrastructure安装向导

运行安装命令,[highlight dark=”no”]Z:\Oinstall>”c:\Program Files\Java\jdk1.8.0_65\bin\java.exe” -jar fmw_12.2.1.0.0_infrastructure.jar[/highlight],欢迎窗口点击Next.

 

wcs12

 

wcs13

 

2.2 跳过自动更新设定

wcs14

2.3 安装路径

选择Weblogic Server安装选择的Oracle Home位置。

wcs15

2.4 选择安装类型

wcs16

2.5 先决条件检查

wcs17

2.6 安装选择汇总

wcs18

点击Install开始进行安装。

2.7 进行Oracle Fusion Middleware Infrastructure的安装

wcs19

2.8 完成Oracle Fusion Middleware Infrastructure的安装

wcs20

[highlight dark=”no”]3. 安装Oracle WebCenter Sites 12c[/highlight]

3.1 运行命令,WebCenter Sites 12c安装向导

运行命令[highlight dark=”no”]Z:\Oinstall\12C>”c:\Program Files\Java\jdk1.8.0_65\bin\java.exe” -jar fmw_12.2.1.0.0_wcsites_generic.jar[/highlight],进入安装向导。

wcs21

 

wcs22

3.2 跳过自动更新

wcs23

3.3 安装位置

选择之前Weblogic Server安装的Oracle Home路径。

wcs24

3.4 安装类型

选择WebCenter Sites和示例网站。

 

wcs25

3.5 先决条件检查

wcs26

3.6 安装汇总

确认所需的功能模块均已选择,点击Install开始进行WebCenter Sites安装。

wcs27

3.7 正式安装WebCenter Sites

正式安装WebCenter Sites

正式安装WebCenter Sites

3.8 完成WebCenter Sites的安装

完成WebCenter Sites的安装

完成WebCenter Sites的安装

 

至此,我们完成了所需软件的安装,下一步是开始进行WebCenter运行所需环境的配置。To be continued……

最近突然对于API以及API管理相关的内容感兴趣,于是上18摸的API Management网站下载了一本《APIs For Dummies》的IBM版本做入门的学习。当看到其中的APIs versus services一节,对于API与服务差异的解释,很是清晰,也解开了自己一直以来的疑问。尤其是利用汽车来比喻API与Service的异同,真令人印象深刻。不惜做一回搬运工,把书中的内容做个归纳。

SOA的核心是服务(Service),单纯从技术的角度来看,其实API也是一种服务。但是否API就等于服务呢,这又不尽然。服务与API最大的差别,是它们设计目标的不同。API总是设计用来吸引预期的使用者,当使用者的需求发生改变API也相应改变。与此相反,对于服务的设计,全局的成本和稳定性往往更加重要。使用汽车来比喻的话,API的设计是赛车,注重于外观和使用,而服务的设计是常规的汽车,更着眼与成本和大批量的生产。

APIs and services address different concerns

APIs and services address different concerns

API的产品本质是面向特定的使用者,对于使用者来说,使用API意味着快速、方便与极短的学习曲线。至少从服务提供者的角度来看,这些设计标准是传统的服务与API的根本性差别。

  • 对服务提供者来说,重用包含于API交付的努力中;对于API的使用者,重用是关乎他们软件的交付速度,不管需要为作为软件一部分的API付出多大的代价。
  • 对于服务提供者来说,共享是关乎效率;对于API使用者,共享是是否方便(如果不方便,该API将没人使用)
  • 对于服务提供者来说,封装是更少的改变;对于API使用者,封装是更短的学习曲线(如果接口太复杂,API将没人使用)

有多少SOA项目没有因为服务提供者和服务使用者间因为服务接口由什么组成的冲突而停滞的?一方面,一个移动应用开发者希望API对于她的应用要足够简单;另一方面,后台团队希望大家使用相同的标准化的服务和数据模型。有没有一种既能满足需求,又不会产生高昂费用的强制双方接受的权宜解决方法呢?

API与服务的结合

SOA是屏蔽服务使用者与后端变化的方法。但是谁能为需求不断变化的前端多渠道应用的服务提供者提供保护呢?结合API和服务可使你沉着应对剧变的环境。服务是由服务提供商整理的应用域的基本功能,API是在这些功能(服务)以易于共享形式的重新包装,产品化。所以说API和服务是互补,而不是相互矛盾的,把API和服务结合在一起,将极大地提高企业创新的整体效益。

纯粹玩票的性质,因为有个朋友需要一个发匿名邮件的工具,自告奋勇说帮他写。本以为手到擒来的事,结果还是折腾了大半天才弄好。

因为服务器上跑着Wordpress,所以就图方便想着用PHPMailer来写。在Github上下了最新的PHPMailer库,照着示例轻而易举地把页面写出来,在本机上用自己网易的私人邮箱发送邮件成功。但换了公司部署在腾讯上的企业邮箱发送时,因为使用了SSL验证,出现了“[highlight dark=”no”]Extension missing: openssl[/highlight]”的错误(如下图所示)。

Send

因为对PHP实在不熟,刚开始还以为是PHPMailer的SMTPSecure设置问题,查了Github上的文档发现就是tls或者ssl两种方式,转回来在PHP配置上找原因,发现只需要把php.ini的[highlight dark=”no”]extension=php_openssl.dll[/highlight]扩展开打,邮件即可发送成功。

不过当真的想发匿名邮件时,却又碰到一个问题,几乎所有邮件服务厂商都不支持设置Mail的From属性与登录的发件人不一样,发送时会报“MAIL FROM command failed,mail from address must be same as authorization user”的错误。无法可施,只能场外求助,还好付老板帮大力支持帮俺架了一个邮件服务器,终于可以在12点前交货,帮朋友发出匿名邮件了。

 

Original shared by Josh David Miller at http://stackoverflow.com/questions/14994391/how-do-i-think-in-angularjs-if-i-have-a-jquery-background/15012542?sgp=2#15012542

在stackoverflow上看到一则很好的关于jQuery背景的人该怎么看AngularJS,忍不住转过来。

1. Don’t design your page, and then change it with DOMmanipulations

In jQuery, you design a page, and then you make it dynamic. This is because jQuery was designed for augmentation and has grown incredibly from that simple premise.

But in AngularJS, you must start from the ground up with your architecture in mind. Instead of starting by thinking “I have this piece of the DOM and I want to make it do X”, you have to start with what you want to accomplish, then go about designing your application, and then finally go about designing your view.

2. Don’t augment jQuery with AngularJS

Similarly, don’t start with the idea that jQuery does X, Y, and Z, so I’ll just add AngularJS on top of that for models and controllers. This is really tempting when you’re just starting out, which is why I always recommend that new AngularJS developers don’t use jQuery at all, at least until they get used to doing things the “Angular Way”.

I’ve seen many developers here and on the mailing list create these elaborate solutions with jQuery plugins of 150 or 200 lines of code that they then glue into AngularJS with a collection of callbacks and $applys that are confusing and convoluted; but they eventually get it working! The problem is that in most cases that jQuery plugin could be rewritten in AngularJS in a fraction of the code, where suddenly everything becomes comprehensible and straightforward.

The bottom line is this: when solutioning, first “think in AngularJS”; if you can’t think of a solution, ask the community; if after all of that there is no easy solution, then feel free to reach for the jQuery. But don’t let jQuery become a crutch or you’ll never master AngularJS.

3. Always think in terms of architecture

First know that single-page applications are applications. They’re not webpages. So we need to think like a server-side developer in addition to thinking like a client-side developer. We have to think about how to divide our application into individual, extensible, testable components.

So then how do you do that? How do you “think in AngularJS”? Here are some general principles, contrasted with jQuery.

The view is the “official record”

In jQuery, we programmatically change the view. We could have a dropdown menu defined as a ul like so:

<ul class="main-menu">
    <li class="active">
        <a href="#/home">Home</a>
    </li>
    <li>
        <a href="#/menu1">Menu 1</a>
        <ul>
            <li><a href="#/sm1">Submenu 1</a></li>
            <li><a href="#/sm2">Submenu 2</a></li>
            <li><a href="#/sm3">Submenu 3</a></li>
        </ul>
    </li>
    <li>
        <a href="#/home">Menu 2</a>
    </li>
</ul>

In jQuery, in our application logic, we would activate it with something like:

$('.main-menu').dropdownMenu();

When we just look at the view, it’s not immediately obvious that there is any functionality here. For small applications, that’s fine. But for non-trivial applications, things quickly get confusing and hard to maintain.

In AngularJS, though, the view is the official record of view-based functionality. Our ul declaration would look like this instead:

<ul class="main-menu" dropdown-menu>
    ...
</ul>

These two do the same thing, but in the AngularJS version anyone looking at the template knows what’s supposed to happen. Whenever a new member of the development team comes on board, she can look at this and then know that there is a directive called dropdownMenu operating on it; she doesn’t need to intuit the right answer or sift through any code. The view told us what was supposed to happen. Much cleaner.

Developers new to AngularJS often ask a question like: how do I find all links of a specific kind and add a directive onto them. The developer is always flabbergasted when we reply: you don’t. But the reason you don’t do that is that this is like half-jQuery, half-AngularJS, and no good. The problem here is that the developer is trying to “do jQuery” in the context of AngularJS. That’s never going to work well. The view isthe official record. Outside of a directive (more on this below), you never, ever, never change the DOM. And directives are applied in the view, so intent is clear.

Remember: don’t design, and then mark up. You must architect, and then design.

Data binding

This is by far one of the most awesome features of AngularJS and cuts out a lot of the need to do the kinds of DOM manipulations I mentioned in the previous section. AngularJS will automatically update your view so you don’t have to! In jQuery, we respond to events and then update content. Something like:

$.ajax({
  url: '/myEndpoint.json',
  success: function ( data, status ) {
    $('ul#log').append('<li>Data Received!</li>');
  }
});

For a view that looks like this:

<ul class="messages" id="log">
</ul>

Apart from mixing concerns, we also have the same problems of signifying intent that I mentioned before. But more importantly, we had to manually reference and update a DOM node. And if we want to delete a log entry, we have to code against the DOM for that too. How do we test the logic apart from the DOM? And what if we want to change the presentation?

This a little messy and a trifle frail. But in AngularJS, we can do this:

$http( '/myEndpoint.json' ).then( function ( response ) {
    $scope.log.push( { msg: 'Data Received!' } );
});

And our view can look like this:

<ul class="messages">
    <li ng-repeat="entry in log">{{ entry.msg }}</li>
</ul>

But for that matter, our view could look like this:

<div class="messages">
    <div class="alert" ng-repeat="entry in log">
        {{ entry.msg }}
    </div>
</div>

And now instead of using an unordered list, we’re using Bootstrap alert boxes. And we never had to change the controller code! But more importantly, no matter where or how the log gets updated, the view will change too. Automatically. Neat!

Though I didn’t show it here, the data binding is two-way. So those log messages could also be editable in the view just by doing this: <input ng-model="entry.msg" />. And there was much rejoicing.

Distinct model layer

In jQuery, the DOM is kind of like the model. But in AngularJS, we have a separate model layer that we can manage in any way we want, completely independently from the view. This helps for the above data binding, maintains separation of concerns, and introduces far greater testability. Other answers mentioned this point, so I’ll just leave it at that.

Separation of concerns

And all of the above tie into this over-arching theme: keep your concerns separate. Your view acts as the official record of what is supposed to happen (for the most part); your model represents your data; you have a service layer to perform reusable tasks; you do DOM manipulation and augment your view with directives; and you glue it all together with controllers. This was also mentioned in other answers, and the only thing I would add pertains to testability, which I discuss in another section below.

Dependency injection

To help us out with separation of concerns is dependency injection (DI). If you come from a server-side language (from Java to PHP) you’re probably familiar with this concept already, but if you’re a client-side guy coming from jQuery, this concept can seem anything from silly to superfluous to hipster. But it’s not. 🙂

From a broad perspective, DI means that you can declare components very freely and then from any other component, just ask for an instance of it and it will be granted. You don’t have to know about loading order, or file locations, or anything like that. The power may not immediately be visible, but I’ll provide just one (common) example: testing.

Let’s say in our application, we require a service that implements server-side storage through a REST API and, depending on application state, local storage as well. When running tests on our controllers, we don’t want to have to communicate with the server – we’re testing the controller, after all. We can just add a mock service of the same name as our original component, and the injector will ensure that our controller gets the fake one automatically – our controller doesn’t and needn’t know the difference.

Speaking of testing…

4. Test-driven development – always

This is really part of section 3 on architecture, but it’s so important that I’m putting it as its own top-level section.

Out of all of the many jQuery plugins you’ve seen, used, or written, how many of them had an accompanying test suite? Not very many because jQuery isn’t very amenable to that. But AngularJS is.

In jQuery, the only way to test is often to create the component independently with a sample/demo page against which our tests can perform DOM manipulation. So then we have to develop a component separately and then integrate it into our application. How inconvenient! So much of the time, when developing with jQuery, we opt for iterative instead of test-driven development. And who could blame us?

But because we have separation of concerns, we can do test-driven development iteratively in AngularJS! For example, let’s say we want a super-simple directive to indicate in our menu what our current route is. We can declare what we want in the view of our application:

<a href="/hello" when-active>Hello</a>

Okay, now we can write a test for the non-existent when-active directive:

it( 'should add "active" when the route changes', inject(function() {
    var elm = $compile( '<a href="/hello" when-active>Hello</a>' )( $scope );

    $location.path('/not-matching');
    expect( elm.hasClass('active') ).toBeFalsey();

    $location.path( '/hello' );
    expect( elm.hasClass('active') ).toBeTruthy();
}));

And when we run our test, we can confirm that it fails. Only now should we create our directive:

.directive( 'whenActive', function ( $location ) {
    return {
        scope: true,
        link: function ( scope, element, attrs ) {
            scope.$on( '$routeChangeSuccess', function () {
                if ( $location.path() == element.attr( 'href' ) ) {
                    element.addClass( 'active' );
                }
                else {
                    element.removeClass( 'active' );
                }
            });
        }
    };
});

Our test now passes and our menu performs as requested. Our development is both iterative and test-driven. Wicked-cool.

5. Conceptually, directives are not packaged jQuery

You’ll often hear “only do DOM manipulation in a directive”. This is a necessity. Treat it with due deference!

But let’s dive a little deeper…

Some directives just decorate what’s already in the view (think ngClass) and therefore sometimes do DOM manipulation straight away and then are basically done. But if a directive is like a “widget” and has a template, it should also respect separation of concerns. That is, the template too should remain largely independent from its implementation in the link and controller functions.

AngularJS comes with an entire set of tools to make this very easy; with ngClass we can dynamically update the class; ngBind allows two-way data binding; ngShow and ngHide programmatically show or hide an element; and many more – including the ones we write ourselves. In other words, we can do all kinds of awesomeness without DOM manipulation. The less DOM manipulation, the easier directives are to test, the easier they are to style, the easier they are to change in the future, and the more re-usable and distributable they are.

I see lots of developers new to AngularJS using directives as the place to throw a bunch of jQuery. In other words, they think “since I can’t do DOM manipulation in the controller, I’ll take that code put it in a directive”. While that certainly is much better, it’s often still wrong.

Think of the logger we programmed in section 3. Even if we put that in a directive, we still want to do it the “Angular Way”. It still doesn’t take any DOM manipulation! There are lots of times when DOM manipulation is necessary, but it’s a lot rarer than you think! Before doing DOM manipulation anywhere in your application, ask yourself if you really need to. There might be a better way.

Here’s a quick example that shows the pattern I see most frequently. We want a toggleable button. (Note: this example is a little contrived and a skosh verbose to represent more complicated cases that are solved in exactly the same way.)

.directive( 'myDirective', function () {
    return {
        template: '<a class="btn">Toggle me!</a>',
        link: function ( scope, element, attrs ) {
            var on = false;

            $(element).click( function () {
                if ( on ) {
                    $(element).removeClass( 'active' );
                }
                else {
                    $(element).addClass( 'active' );
                }

                on = !on;
            });
        }
    };
});

There are a few things wrong with this:

  1. First, jQuery was never necessary. There’s nothing we did here that needed jQuery at all!
  2. Second, even if we already have jQuery on our page, there’s no reason to use it here; we can simply use angular.element and our component will still work when dropped into a project that doesn’t have jQuery.
  3. Third, even assuming jQuery was required for this directive to work, jqLite (angular.element) willalways use jQuery if it was loaded! So we needn’t use the $ – we can just use angular.element.
  4. Fourth, closely related to the third, is that jqLite elements needn’t be wrapped in $ – the element that is passed to the link function would already be a jQuery element!
  5. And fifth, which we’ve mentioned in previous sections, why are we mixing template stuff into our logic?

This directive can be rewritten (even for very complicated cases!) much more simply like so:

.directive( 'myDirective', function () {
    return {
        scope: true,
        template: '<a class="btn" ng-class="{active: on}" ng-click="toggle()">Toggle me!</a>',
        link: function ( scope, element, attrs ) {
            scope.on = false;

            scope.toggle = function () {
                scope.on = !scope.on;
            };
        }
    };
});

Again, the template stuff is in the template, so you (or your users) can easily swap it out for one that meets any style necessary, and the logic never had to be touched. Reusability – boom!

And there are still all those other benefits, like testing – it’s easy! No matter what’s in the template, the directive’s internal API is never touched, so refactoring is easy. You can change the template as much as you want without touching the directive. And no matter what you change, your tests still pass.

w00t!

So if directives aren’t just collections of jQuery-like functions, what are they? Directives are actuallyextensions of HTML. If HTML doesn’t do something you need it to do, you write a directive to do it for you, and then use it just as if it was part of HTML.

Put another way, if AngularJS doesn’t do something out of the box, think how the team would accomplish it to fit right in with ngClick, ngClass, et al.

Summary

Don’t even use jQuery. Don’t even include it. It will hold you back. And when you come to a problem that you think you know how to solve in jQuery already, before you reach for the $, try to think about how to do it within the confines the AngularJS. If you don’t know, ask! 19 times out of 20, the best way to do it doesn’t need jQuery and to try to solve it with jQuery results in more work for you.

这篇文章主要描述Oracle ADF Mobile开发环境的搭建工作。由于还没有测试过在window下搭建IOS的开发环境,所以此次只是描述JDeveloper的环境配置和Android开发环境搭建。

Android开发环境搭建

1.下载SDK

访问:http://developer.android.com/sdk/index.html ,下载SDK 。

 

无标题

根据我们的开发环境下载32位或64位。此处我们下载的是64位的SDK(adt-bundle-windows-x86_64-20140321.zip)。

2.安装SDK

将下载的zip文件解压到某个目录(不要中文、不要空格)。运行其目录下的SDK Manager.exe。参照下面的图示将相关选项选中(注意要将下方的Obsolete选中)。

选择需要安装的组件后按“Install packages”按钮进行安装。

无标题无标题

3.配置虚拟机

安装完成可以创建虚拟机。选择“Tools” — > “Manage AVDs”。开启虚拟机创建页面。

点击“New”按钮,创建虚机。如下图所示:

无标题1

无标题

点击“Start”按钮即可启动虚机。虚机启动后如下图。

无标题3

 

JDeveloper环境配置

1.安装JDeveloper

请安装11.1.2.4.0版本,安装JDeveloper不再描述

2.安装ADF Mobile插件

启动JDeveloper,选择Help–>Check for Updates,找到Oracle ADF Mobile,进行安装。目前最新版本如下:

无标题

 

3.配置JDeveloper

选择Tools –>Preferences。如下图配置Android的相关信息。

无标题

注意第三栏灰色的部分“Android Build Tools Location”,请选择正确的地址(早期的安卓版本在sdk/platform-tools下)。

 

至此开发环境搭建完成,在下一篇教程中我们将制作一个简单的APP应用。

 

 

重装系统和Visual Studio 2012后,打开以前托管在Team Fundation Service的Git中的代码,结果死活在Visual Studio中连接不上服务器,报以下TF31003的错误:

TF31003: Either you have not entered the necessary credentials or your user account does not have permission to connect to the Team Foundation Server at https://***.visualstudio.com/. Ask your server administrator to add the appropriate permissions to your account.

不断的登录再登出还是没法解决问题。

解决方法:

折腾了老半天,才发现是IE的cookie导致的,也许是平时用多个不同outlook.com的ID登录过导致吧。在IE中按Ctrl + Shift + Delete,打开窗口,点击删除。

然后再到Visual Studio 2012连接服务器,终于重新出来登录界面。


用VS死活无法同步TFS上的Git代码,一直报网络错误。一怒之下想着就用客户端工具把代码先同步了再说,结果用Git客户端一合并代码用Windows Live Id却一再报身份验证错误,确认用户名和密码都是正确的。

解决方法:

1.在Web登录TFS账户,点击你的账户名,选择“My Profile”.

2.选择“CREDIENTIALS”,点击下面的“Enable alternate credentials”,输入可选账号与密码,点击确认。

3.重新用Git GUI登录同步代码,一切工作正常。

1.安装配置LAMP Server

  • 进入root用户模式

[highlight dark=”no”] sudo –s –H [/highlight]

  • 安装MySql 

[highlight dark=”no”]    apt-get install mysql-server mysql-client [/highlight]

  • 安装Apache

[highlight dark=”no”]apt-get install apache2 [/highlight]

  • 安装PHP支持 

[highlight dark=”no”]  apt-get install php5 libapache2-mod-php5 [/highlight]

  • 创建info.php文件,确认PHP文件能够正常解析 

[highlight dark=”no”]  vi /var/www/info.php [/highlight]

           <?php

               phpinfo();

            ?>   

[highlight dark=”no”]/etc/init.d/apache2 restart [/highlight]

http://localhost/info.php

2. 安装并配置Wordpress

  • 安装Wordpress 

[highlight dark=”no”]apt-get install wordpress [/highlight]

  • 创建web要目录与wordpress的软链接 

[highlight dark=”no”] ln –s /usr/share/wordpress  /var/www [/highlight]

  • 解压并安装wordpress数据库 

[highlight dark=”no”]gzip -d /usr/share/doc/wordpress/examples/setup-mysql.gz[/highlight]

[highlight dark=”no”]bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost [/highlight]

  • 重启web服务,确认wordpress可以访问 

[highlight dark=”no”] /etc/init.d/apache2 restart[/highlight]

访问 http://localhost/wordpress可进行wordpress的设置.

3. 注意事项

  • 如果要使用WordPress的自动更新功能,必须把WordPress安装文件夹的所有权改为www-data用户 

[highlight dark=”no”]chown -R www-data /usr/share/wordpress [/highlight]

  • 若是要使用IP地址访问WordPress,必须做以下设置 

a).更改数据库中wp_options表下的siteurl内容,将其更改为宿主机的ip。如http://192.168.2.16/wordpress

b).更改数据库中wp_options表下的home内容(这个大概在第二页),同样改为http://192.168.2.16/wordpress

c).连接配置文件

[highlight dark=”no”] ln -s /etc/wordpress/config-localhost.php /etc/wordpress/config-default.php [/highlight]

  • 如果模板或插件不能上传,需要改变wordpress配置文件WP_CONTENT_DIR指向到实际目录 

[highlight dark=”no”]vi /etc/wordpress/config-localhost.php [/highlight]

define(‘WP_CONTENT_DIR’, ‘/var/www/wordpress/wp-content’);

 

友好的URL访问:

再也不用去写复杂的URL封装器解装器了

Mobile的支持

Segment界面的美化

与Webcenter Content的集成


安装论坛模块与gadgets更简单的安装

前言:

一个站点完美的用户体验往往体现在各种细节当,友好的URL也是增强用户体验的一个小细节,Webcenter sites也提供了URL美化的解决方案。

解决方案:

跟其它sites中的功能一样,URL美化的解决方案也在FirstSiteII站点中给出了相应的例子,

在webcenter sites安装CD(即安装包)中的如下目录下找到FSIIAssembler.java文件:

/ContentServer/FirstSiteII/PrettyURL/src/com/
fatwire/firstsite/uri/FSIIAssembler.java

默认此URL装配器是配制上的,如果你访问FirstSiteII站点的话,则会调用此过滤器,当然需要满足过滤器条件规则的URL才能够正常触发。在domainCSWEB-INFclasses目录下找到ServletRequest.properties文件,使用propeditor打开文件:

你自己定制的装配器配制在红框中的两个属性中。当然,FirstSiteII站点默认的装配器就是配制在这里的。

 

我们如果在firestSiteII站点中,使用如下规则访问站点:

…ContentServer/[site]/[sitepfx]/[cid]

则会触发FSIIAssembler.java java类,你可以通过远程debug的方式来跟踪此类来具体了解URL装配器是如何工作的。

 

原理举例说明:

下面以用户通过 URL 访问站点页面来说明下sites的封装器。

用户输入URL访问站点页面

调用解装方法,将URI path进行解析,然后将解析后得到的参数放入sites的上下文中

在页面渲染的时候,对页面中使用render:getpageurl标签的地方则会调用装配器的装配方法,根据我们定制的规则将页面上的链接装配好给用户点击使用。

 

主要工作的方法有两个,即解装跟装配两个方法:

解装方法:protected DisassemblyContext getDisassemblyContext(URI uri)

装配方法:getAssemblyContext(Definition def)

0 评论/通过: