Based on JSF-Component's constructs usually need to understand a few more 1. All JSF-Components are single instance, that is to say, one UI component only has one instance 2 in the UI component during each session period. Variables, for objects that do not belong to the UI component, passed the constructor at the beginning of the UI object building, and thereafter, the UI is still an instance of the object in the UI, regardless of any changes in other places. For UI component's own object, if it assigns it with the setxx method, the UI object is in eNCode, the current value of the object is also used. Public Class UiFileform Extends UisimpleForm {Static Final Public String Save_Action = "Save"; Static Final Public String Cancel_Action = "CANCEL";
Private ftpfile ftpfile_; private ftpclient ftpclient_; private uistringinput nameinput_; private string filename_;
Public uiFileform (FTPCLIENT FTP, ResourceBundle Res) THROWS Exception {Super ("Fileform", "POST", NULL); SetID ("UIFILEFORM"); setClazz ("UIFILEFORM"); ftpclient_ = ftp; // Reference External Object INT IDX = ftpfile_.getname (). LastIndexof ("/"); string filename = ftpfile_.getname (). Substring (IDX ); NameInput_ = new uiStringInput ("name", filename);
Add (New Headerrow (). Add ("Header.edit-file"). AddColspan ("2"))); add (new row (). add (new labelcell (res. maxString ("Label.file-name")))))))))))))))))))); // Although it is in the constructor, nameinput is an object, all even if its value changes, eNCode Still not yet the changed value add (New ListComponentcell () .add ("Button.Save", Save_Action) .add (res. max ("Button.cancel"), cancel_action)) .addcolspan ("2") .addalign ("center")))