Control.jvm.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. //
  2. // System.Web.UI.ControlS.jvm.cs
  3. //
  4. // Authors:
  5. // Eyal Alaluf ([email protected])
  6. //
  7. // (C) 2006 Mainsoft Co. (http://www.mainsoft.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System.Web.Hosting;
  30. using System.Text;
  31. using javax.faces.component;
  32. using java.util;
  33. using javax.faces.el;
  34. using javax.faces.@event;
  35. using javax.faces.context;
  36. namespace System.Web.UI
  37. {
  38. public partial class Control : UIComponent, StateHolder
  39. {
  40. ComponentChildrenList _childrenList;
  41. protected override void addFacesListener (FacesListener __p1) {
  42. throw new Exception ("The method or operation is not implemented.");
  43. }
  44. public override void broadcast (FacesEvent __p1) {
  45. throw new Exception ("The method or operation is not implemented.");
  46. }
  47. public override void decode (FacesContext context) {
  48. // do nothing
  49. }
  50. public override void encodeBegin (FacesContext __p1) {
  51. throw new Exception ("The method or operation is not implemented.");
  52. }
  53. public override void encodeChildren (FacesContext __p1) {
  54. throw new Exception ("The method or operation is not implemented.");
  55. }
  56. public override void encodeEnd (FacesContext __p1) {
  57. throw new Exception ("The method or operation is not implemented.");
  58. }
  59. public override UIComponent findComponent (string __p1) {
  60. throw new Exception ("The method or operation is not implemented.");
  61. }
  62. public override Map getAttributes () {
  63. throw new Exception ("The method or operation is not implemented.");
  64. }
  65. public override int getChildCount () {
  66. throw new Exception ("The method or operation is not implemented.");
  67. }
  68. public override List getChildren () {
  69. if (_childrenList == null)
  70. _childrenList = new ComponentChildrenList (this);
  71. return _childrenList;
  72. }
  73. public override string getClientId (FacesContext __p1) {
  74. throw new Exception ("The method or operation is not implemented.");
  75. }
  76. protected override FacesContext getFacesContext () {
  77. Page page = Page;
  78. if (page != null)
  79. return page.getFacesContext ();
  80. return FacesContext.getCurrentInstance ();
  81. }
  82. protected override FacesListener [] getFacesListeners (java.lang.Class __p1) {
  83. throw new Exception ("The method or operation is not implemented.");
  84. }
  85. public override UIComponent getFacet (string __p1) {
  86. throw new Exception ("The method or operation is not implemented.");
  87. }
  88. public override Map getFacets () {
  89. throw new Exception ("The method or operation is not implemented.");
  90. }
  91. public override Iterator getFacetsAndChildren () {
  92. // TODO: consider facets.
  93. return getChildren ().iterator ();
  94. }
  95. public override string getFamily () {
  96. throw new Exception ("The method or operation is not implemented.");
  97. }
  98. public override string getId () {
  99. throw new Exception ("The method or operation is not implemented.");
  100. }
  101. public override UIComponent getParent () {
  102. throw new Exception ("The method or operation is not implemented.");
  103. }
  104. protected override javax.faces.render.Renderer getRenderer (FacesContext __p1) {
  105. throw new Exception ("The method or operation is not implemented.");
  106. }
  107. public override string getRendererType () {
  108. throw new Exception ("The method or operation is not implemented.");
  109. }
  110. public override bool getRendersChildren () {
  111. throw new Exception ("The method or operation is not implemented.");
  112. }
  113. public override ValueBinding getValueBinding (string name) {
  114. return null;
  115. }
  116. public override bool isRendered () {
  117. throw new Exception ("The method or operation is not implemented.");
  118. }
  119. // TODO: implement
  120. public override void processDecodes (FacesContext context) {
  121. // call processDecodes for all jsf children
  122. }
  123. public override void processRestoreState (FacesContext context, object state) {
  124. throw new NotSupportedException ();
  125. }
  126. public override object processSaveState (FacesContext context) {
  127. throw new NotSupportedException ();
  128. }
  129. // TODO: implement
  130. public override void processUpdates (FacesContext context) {
  131. // call processUpdates for all jsf children
  132. }
  133. // TODO: implement
  134. public override void processValidators (FacesContext context) {
  135. // call processValidators for all jsf children
  136. }
  137. public override void queueEvent (FacesEvent __p1) {
  138. throw new Exception ("The method or operation is not implemented.");
  139. }
  140. protected override void removeFacesListener (FacesListener __p1) {
  141. throw new Exception ("The method or operation is not implemented.");
  142. }
  143. public override void setId (string __p1) {
  144. throw new Exception ("The method or operation is not implemented.");
  145. }
  146. public override void setParent (UIComponent __p1) {
  147. throw new Exception ("The method or operation is not implemented.");
  148. }
  149. public override void setRendered (bool __p1) {
  150. throw new Exception ("The method or operation is not implemented.");
  151. }
  152. public override void setRendererType (string __p1) {
  153. throw new Exception ("The method or operation is not implemented.");
  154. }
  155. public override void setValueBinding (string name, ValueBinding binding) {
  156. throw new NotSupportedException ();
  157. }
  158. #region StateHolder Members
  159. bool StateHolder.isTransient () {
  160. return !EnableViewState;
  161. }
  162. void StateHolder.restoreState (FacesContext context, object state) {
  163. LoadViewState (state);
  164. }
  165. object StateHolder.saveState (FacesContext context) {
  166. return SaveViewState ();
  167. }
  168. void StateHolder.setTransient (bool newTransientValue) {
  169. EnableViewState = !newTransientValue;
  170. }
  171. #endregion
  172. class ComponentChildrenList : AbstractList
  173. {
  174. Control _owner;
  175. public ComponentChildrenList (Control owner) {
  176. _owner = owner;
  177. }
  178. public override object get (int index) {
  179. return _owner.Controls [index];
  180. }
  181. public override int size () {
  182. return _owner.Controls.Count;
  183. }
  184. }
  185. public virtual string TemplateSourceDirectory
  186. {
  187. get
  188. {
  189. if (_templateSourceDirectory == null) {
  190. _templateSourceDirectory = VirtualPathUtility.ToAbsolute (AppRelativeTemplateSourceDirectory, false);
  191. if (_templateSourceDirectory.Length > 1 &&
  192. _templateSourceDirectory [_templateSourceDirectory.Length - 1] == '/')
  193. _templateSourceDirectory = _templateSourceDirectory.Substring (0, _templateSourceDirectory.Length - 1);
  194. }
  195. return _templateSourceDirectory;
  196. }
  197. }
  198. string ResolveAppRelativeFromFullPath (string url) {
  199. Uri uri = new Uri (url);
  200. if (String.Compare (uri.Scheme, Page.Request.Url.Scheme, StringComparison.OrdinalIgnoreCase) == 0 &&
  201. String.Compare (uri.Host, Page.Request.Url.Host, StringComparison.OrdinalIgnoreCase) == 0 &&
  202. uri.Port == Page.Request.Url.Port)
  203. return VirtualPathUtility.ToAppRelative (uri.PathAndQuery);
  204. return url;
  205. }
  206. internal string CreateActionUrl (string relativeUrl) {
  207. relativeUrl = ResolveClientUrlInternal (relativeUrl);
  208. FacesContext faces = getFacesContext ();
  209. if (faces == null)
  210. return relativeUrl;
  211. string url;
  212. if (relativeUrl.IndexOf (':') >= 0)
  213. url = ResolveAppRelativeFromFullPath (relativeUrl);
  214. else if (VirtualPathUtility.IsAbsolute (relativeUrl))
  215. url = VirtualPathUtility.ToAppRelative (relativeUrl);
  216. else
  217. return faces.getApplication ().getViewHandler ().getActionURL (faces, relativeUrl);
  218. if (VirtualPathUtility.IsAppRelative (url)) {
  219. url = url.Substring (1);
  220. url = url.Length == 0 ? "/" : url;
  221. return faces.getApplication ().getViewHandler ().getActionURL (faces, url);
  222. }
  223. return relativeUrl;
  224. }
  225. internal string ResolveClientUrl (string relativeUrl, bool usePortletRenderResolve) {
  226. if (usePortletRenderResolve)
  227. return ResolveClientUrl (relativeUrl);
  228. else
  229. return ResolveUrl (relativeUrl);
  230. }
  231. }
  232. }