独自のカスタム・タグ・エディタを作成して、JDeveloperのコンポーネント・パレットやJSP 1.1および1.2のカスタム・タグ・テクノロジで使用できます。独自のカスタム・タグ・エディタを実装する手順は、次のとおりです。
palette.xml
にある)にエディタを登録します。
次の手順では、単純なカスタム・タグ・エディタの作成方法を説明します。この手順では、ワークスペース、プロジェクト、およびファイルの作成など、基本的なJDeveloperの機能を理解していることを前提としています。
単純なカスタム・タグ・エディタを作成するには、次のようにします。
MyTagEditor
という名前を付けます。
.jpr
)をダブルクリックして、「プロジェクトの設定」ダイアログを開きます。 ツリーで「構成」を開き、「Development」を開いて「ライブラリ」を選択し、プロジェクトの選択済のライブラリのリストに「JDeveloper」ライブラリを追加します。
MyTagEditor.java
に、次のコードを追加します。 package package1;
import java.util.ArrayList;
import oracle.ide.addin.Context;
import oracle.jdevimpl.jsp.tags.taglib.model.Tag;
import oracle.jdevimpl.jsp.wizards.tageditor.TagEditorWizard;
import oracle.jdevimpl.jsp.tags.wizard.JspTagBuilder;
import oracle.jdeveloper.jsp.utils.JSPTagUtils;
public class MyTagEditor extends TagEditorWizard
{
public boolean invoke( Context ctx, String[] params )
{
String jspTagLibrary = params[ 0 ];
String tagName = params[ 1 ];< /FONT >
// Sets all necessary getters and setters for you to use.
setAttributes( jspTagLibrary, tagName );
// Retrieve Tag
Tag tag = getTag();
/**
* Here, you would build your own UI using the Tag object above.
* You must return an Iterator of Object Arrays contaning both the name
* of the attribute and it's assigned value, if any.
* Example for a simple tag with attributes foo and foo1 with assigned values.
*/
// Hard Coding simple attribute name - value pairing. Would normally be generated
// by what the user specifies in your UI.
ArrayList attrList = new ArrayList();
String[] foo = { "foo", "fooValue" };
String[] foo1 = { "foo1", "foo1Value" };
attrList.add( foo );
attrList.add( foo1 );
// To Insert a Tag WITH Attributes into the Java Code Editor, uncomment the following.
/*JSPTagUtils.doAll( getLibrary(),
JspTagBuilder.buildInsertTag( getTag(),
getLibrary(),
attrList.iterator() ) );
*/
//To Insert a Tag without attributes into the Java Code Editor, uncomment the following
//JSPTagUtils.doAll( getLibrary(), getTag() );
return true;
}
}
<JDEV_HOME\jdev\lib\ext>
へデプロイします。「ファイル」->「新規」を選択して「General」を開き、「Deployment Profiles」を選択して「JARファイル - シンプル・アーカイブ」をダブルクリックします。 次に、アプリケーション・ナビゲータで.deploy
ファイルを右クリックし、「JARファイルにデプロイ」を選択します。
palette.xmlファイル内の指定されたタグ項目にエディタを追加するには、次のようにします。
<JDEV_HOME>\jdev\system
にあるpalette.xml
ファイルを開きます。
<item>
タグを検索します。 <item>
<icon>/oracle/ideimpl/resource/images/palette/jsp.gif</icon>
<info>util</info>
<longLabel>Displays when a JSP page was last modified.</longLabel>
<shortLabel>lastModified</shortLabel>
<type>jsptag</type>
</item>
<item>
要素に、エディタ・タグを追加します。 <item>
<icon>/oracle/ideimpl/resource/images/palette/jsp.gif</icon>
<info>util</info>
<longLabel>Displays when a JSP page was last modified.</longLabel>
<shortLabel>lastModified</shortLabel>
<type>jsptag</type>
<editor>package1.MyTagEditor</editor>
</item>
JDeveloperのJSPカスタム・タグ・ライブラリについて
カスタムJSPタグ・ライブラリの作成
カスタム・タグ・インサイト・エディタの作成
詳細は、次のURLでJavaServer Pages仕様を参照してください。http://java.sun.com/products/jsp/index.html
Copyright © 1997, 2004, Oracle. All rights reserved.