Control.jvm.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.context;
  32. namespace System.Web.UI
  33. {
  34. public partial class Control
  35. {
  36. public virtual string TemplateSourceDirectory
  37. {
  38. get
  39. {
  40. if (_templateSourceDirectory == null) {
  41. _templateSourceDirectory = VirtualPathUtility.ToAbsolute (AppRelativeTemplateSourceDirectory, false);
  42. if (_templateSourceDirectory.Length > 1 &&
  43. _templateSourceDirectory [_templateSourceDirectory.Length - 1] == '/')
  44. _templateSourceDirectory = _templateSourceDirectory.Substring (0, _templateSourceDirectory.Length - 1);
  45. }
  46. return _templateSourceDirectory;
  47. }
  48. }
  49. string ResolveAppRelativeFromFullPath (string url) {
  50. Uri uri = new Uri (url);
  51. if (String.Compare (uri.Scheme, Page.Request.Url.Scheme, StringComparison.OrdinalIgnoreCase) == 0 &&
  52. String.Compare (uri.Host, Page.Request.Url.Host, StringComparison.OrdinalIgnoreCase) == 0 &&
  53. uri.Port == Page.Request.Url.Port)
  54. return VirtualPathUtility.ToAppRelative (uri.PathAndQuery);
  55. return url;
  56. }
  57. internal string CreateActionUrl (string url) {
  58. FacesContext faces = getFacesContext ();
  59. if (faces == null)
  60. return url;
  61. url = Asp2Jsf (url);
  62. return faces.getApplication ().getViewHandler ().getActionURL (faces, url);
  63. }
  64. string Asp2Jsf (string url) {
  65. if (VirtualPathUtility.IsAbsolute (url))
  66. url = VirtualPathUtility.ToAppRelative (url);
  67. if (VirtualPathUtility.IsAppRelative (url)) {
  68. url = url.Substring (1);
  69. return url.Length == 0 ? "/" : url;
  70. }
  71. return url;
  72. }
  73. internal string ResolveClientUrl (string relativeUrl, bool usePortletRenderResolve) {
  74. if (usePortletRenderResolve)
  75. return ResolveClientUrl (relativeUrl);
  76. else
  77. return ResolveUrl (relativeUrl);
  78. }
  79. internal bool IsLoaded {
  80. get { return (stateMask & LOADED) != 0; }
  81. }
  82. internal bool IsPrerendered {
  83. get { return (stateMask & PRERENDERED) != 0; }
  84. }
  85. }
  86. }