2014年8月26日 星期二

CCS 如何引用物件(referencing objects)?

在CCS中如何引用一個物件?

引用物件(Referencing Objects)

由CCS產生的應用程式的物件,可以有很多種引用的方法。
要引用一個物件,你應該要知道這個物件存在網頁程式中的階層位置。舉例來說:你必須弄清楚,這個物件是直接位於頁上的,還是頁裡的表單裡的物件。頁-page是一個物件、表單-Form也是一個物件。


PHP

在PHP裡面,你可以直接使用 $Component 來指引到發出該事件的元件, $Container 則是指引到存放該 $Component 的物件,也就是說 $Component 的上一層級物件。
使用 $Component 及 $Container 這個方法建議使用在可以重複使用的程式碼上,因為它並沒有直接使用名稱指引,所以,可以被重複利用。
另一個方法,就是直接使用廣域變數名稱來指引要該物件,例如:使用 $MyGrid 來指引到 "MyGrid" 這個grid 物件。


各種指引到物件的例子 語  法
頁面裡面的表單物件Form object placed on a page 頁面事件
Page Events
$Component->form->visible = false;
表單事件
Form Events
$Component->Visible = false;
表單裡面的控制項物件
Control object placed within a form
頁面事件
Page Events
$Component->form->control->SetValue($Component->form->PageNumber);
表單事件
Form Events
$Component->control->SetValue($Component->PageNumber);
控制項物件事件
Control Events
$Component->SetValue($Container->PageNumber);
頁面物件裡面的控制項物件
Control object placed on a page
頁面事件
Page Events
$Component->control->SetValue("ABC");
控制項事件
Control Events
$Component->SetValue("ABC");
在"包含頁面"(included page)物件裡面的控制項物件
Control object placed on an included page
主頁面事件
Main Page Events
$Component->page->control->Visible = false;
包含頁面事件
Includable Page  Events
$Component->control->Visible = false;
控制項物件事件
Control Events
$Component->Visible = false;
在"包含頁面"裡面的表單物件
Form object placed on an included page
主頁面事件
Main Page Events
$Component->page->form->Visible = false;
包含頁事件
Includable Page  Events
$Component->form->Visible = false;
表單事件
Form Events
$Component->Visible = false;
存在包含頁裡面的表單裡的控制項物件
Control object placed in a form within an  included page 
主頁面事件
Main Page Events
$Component->page->form->control->Visible = false;
包含頁事件
Includable Page  Events
$Component->form->control->Visible = false;
表單事件
Form Events
$Component->control->Visible = false;
控制項事件
Control Events
$Component->Visible = false;


使用廣域變數名稱的例子 語法
頁面裡的表單物件
Form object placed on a page
$form->Visible = false;
表單裡的控制項物件
Control object placed within a form
$form->control->SetValue("123");
頁面裡的控制項物件
Control object placed on a page
$control->SetValue("ABC");
包含頁裡的控制項物件
Control object placed on an included page
$page->control->Visible = false;
包含頁裡的表單物件
Form object placed on an included page
$page->form->Visible = false;
包含頁裡的表單裡的控制項物件
Control object placed in a form within an  included page 
$page->form->control->Visible = false;

Perl

Examples of working with objects Syntax
Form object placed on a page $<form>->{Visible} = 0;
Control object placed within a form $<form>->{<control>}->SetValue("123");
Control object placed on a page $<control>->SetValue("ABC");
Control object placed on an included page $<page>->{<control>}->{Visible} = 0;
Form object placed on an included page $<page>->{<form>}->{Visible} = 0;
Control object placed in a form within an included page  $<page>->{<form>}->{<control>}->{Visible} = 0;
Assigning an object to a variable $<variable> = $<object>;

Java

Examples of working with objects Syntax
Form object placed on a page Page Events e.getPage().getComponent("<form>").setVisible(false);
Form Events e.getComponent().setVisible(false);
Control object placed within a form Page Events e.getPage().getComponent("<form>").getControl("<control>").setValue("123");
Form Events e.getComponent().getControl("<control>").setValue("123");
Control Events e.getControl().setValue("123");
Control object placed on a page Page Events e.getPage().getControl("<control>").setValue("ABC");
Control Events e.getControl().setValue("ABC");
Assigning an object to a variable <variable> = <object>;
Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above. The syntax for accessing objects in an included page from events within the including page is not supported. The syntax for accessing objects in the including page from events within the included page is also not supported.

C#

Examples of working with objects Syntax
Form object placed on a page Grid and Editable Grid Events <form>Repeater.Visible = false;
Record Events <form>Holder.Visible = false;
Directory and Path Events <form>.Visible = false;
Control object placed within a Record form <form><control>.Visible = false;
Control object placed within a Grid, Editable Grid, Directory and Path form Control's Before Show Event <form><control>.Visible = false;
Form's Before Show and Before Show Row Event Object reference should be retrieved from the FormControls collection.
See the ItemDataBound Event MSDN example.
Control object placed on a page <control>.Visible = false;
Assigning an object to a variable <variable> = <object>;
Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above. The syntax for accessing objects in an included page from events within the including page is not supported. The syntax for accessing objects in the including page from events within the included page is also not supported.

VB.Net

Examples of working with objects Syntax
Form object placed on a page Grid and Editable Grid Events <form>Repeater.Visible = False
Record Events <form>Holder.Visible = False
Directory and Path Events <form>.Visible = False
Control object placed within a Record form <form><control>.Visible = False
Control object placed within a Grid, Editable Grid, Directory and Path form Control's Before Show Event <form><control>.Visible = False
Form's Before Show and Before Show Row Event Object reference should be retrieved from the FormControls collection.
See the ItemDataBound Event MSDN example.
Control object placed on a page <control>.Visible = False
Assigning an object to a variable <variable> = <object>
Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above. The syntax for accessing objects in an included page from events within the including page is not supported. The syntax for accessing objects in the including page from events within the included page is also not supported.

ColdFusion

Examples of working with objects Syntax
Form variable placed on a page or within a form <CFSET blnReadAllowed<form>=false>
Control variable placed within a form or a page <CFSET fld<control> = "abc">
Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above.


如果引用的物件是在於一個Panel裡面,似乎有問題了。 如果一個物件存在於一個Panel裡面,文件上寫說 Panel 是透通的,也就是說引用物件的階層上, Panel是透明的,可以不管,可是,實際上卻發現不行! 在相同的 Panel 裡面,可以很輕易的引用到其他物件,但在 Panel 外面,或其他的 Panel 就會引用不到物件! 例如: members record -obj1 -obj2 -panel1 --obj3 --obj4 -panel2 --obj5 --obj6 在panel1裡面的 obj3 可以使用 members->obj4->getvalue() 引用到物件 可是 obj3 裡面使用 members->obj1->getvalue() 卻引用不到 在 obj1 可以使用 members->obj2->getvalue(), members->obj5->getvalue() 都可以引用到! 換句話說:在panel外面的物件,panel 就是透明的,可以引用到panel裡面的物件 而在panel裡面的物件,panel就不是透明的了,可以引用同層的物件,無法引用到panel外面的物件! 此時,只好變通一下了 在 panel 外面而裡面要用到的,重複一個hidden 的物件到裡面去! 只好這樣了!

沒有留言:

張貼留言

如何判斷現在FORM是在 insert mode? 還是 update mode?

只要用  if (empty({primary_key})) 就可以知道是否為新增模式了。 如果 {promary_key} 是空白的,那麼就是在新增模式;反之,就是更新模式。 以上。