1 /* 2 * Copyright (c) 2002-2022, City of Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.portal.web.xpages; 35 36 import fr.paris.lutece.util.ReferenceItem; 37 import fr.paris.lutece.util.ReferenceList; 38 import fr.paris.lutece.util.xml.XmlUtil; 39 40 /** 41 * This class represents XPage object 42 * 43 */ 44 public class XPage 45 { 46 private static final String TAG_PAGE_LINK = "page_link"; 47 private static final String TAG_PAGE_NAME = "page-name"; 48 private static final String TAG_PAGE_URL = "page-url"; 49 private String _strContent; 50 private String _strTitle; 51 private String _strKeyword; 52 private String _strPathLabel; 53 private String _strXmlExtendedPathLabel; 54 private boolean _bStandalone; 55 private boolean _bSendRedirect; 56 57 /** 58 * 59 * @return The content of the page 60 */ 61 public String getContent( ) 62 { 63 return _strContent; 64 } 65 66 /** 67 * 68 * @return The keyword of the page 69 */ 70 public String getKeyword( ) 71 { 72 return _strKeyword; 73 } 74 75 /** 76 * 77 * @return The title of the page 78 */ 79 public String getTitle( ) 80 { 81 return _strTitle; 82 } 83 84 /** 85 * 86 * @return The path label of the page 87 */ 88 public String getPathLabel( ) 89 { 90 return _strPathLabel; 91 } 92 93 /** 94 * 95 * @param strContent 96 * The content of the page 97 */ 98 public void setContent( String strContent ) 99 { 100 _strContent = strContent; 101 } 102 103 /** 104 * 105 * @param strKeyword 106 * The keyword of the page 107 */ 108 public void setKeyword( String strKeyword ) 109 { 110 _strKeyword = strKeyword; 111 } 112 113 /** 114 * 115 * @param strTitle 116 * The title of the page 117 */ 118 public void setTitle( String strTitle ) 119 { 120 _strTitle = strTitle; 121 } 122 123 /** 124 * 125 * @param strPathLabel 126 * The path label of the page 127 */ 128 public void setPathLabel( String strPathLabel ) 129 { 130 _strPathLabel = strPathLabel; 131 } 132 133 /** 134 * Get the extended path label, which is given as a Xml code 135 * 136 * @return Returns the Extended Path Label 137 */ 138 public String getXmlExtendedPathLabel( ) 139 { 140 return _strXmlExtendedPathLabel; 141 } 142 143 /** 144 * Set the Extended Path Label from a xml string 145 * 146 * @param strXmlExtendedPathLabel 147 * the Extended Path Label to set 148 */ 149 public void setXmlExtendedPathLabel( String strXmlExtendedPathLabel ) 150 { 151 _strXmlExtendedPathLabel = strXmlExtendedPathLabel; 152 } 153 154 /** 155 * Build a path from a referencelist. Each item of the list is an element of the path The item's code is the label, the item's name is used for the URL of 156 * the link. 157 * 158 * @param listPathItem 159 * The items of the path. 160 */ 161 public void setExtendedPathLabel( ReferenceList listPathItem ) 162 { 163 StringBuffer sbXml = new StringBuffer( ); 164 165 for ( ReferenceItem item : listPathItem ) 166 { 167 XmlUtil.beginElement( sbXml, TAG_PAGE_LINK ); 168 XmlUtil.addElement( sbXml, TAG_PAGE_NAME, item.getCode( ) ); 169 XmlUtil.addElement( sbXml, TAG_PAGE_URL, item.getName( ) ); 170 XmlUtil.endElement( sbXml, TAG_PAGE_LINK ); 171 } 172 173 _strXmlExtendedPathLabel = sbXml.toString( ); 174 } 175 176 /** 177 * Indicates if the content is standalone and should not be encapsulated in other content, such as portal headers and footers 178 * 179 * @return <code>true</code> is the content is standalone 180 * @since 5.1.0 181 */ 182 public boolean isStandalone( ) 183 { 184 return _bStandalone; 185 } 186 187 /** 188 * Indicates if the content is standalone and should not be encapsulated in other content, such as portal headers and footers 189 * 190 * @param standalone 191 * <code>true</code> is the content is standalone 192 * @since 5.1.0 193 */ 194 public void setStandalone( boolean standalone ) 195 { 196 _bStandalone = standalone; 197 } 198 199 /** 200 * Indicate if a response send Redirect have bean call during treatment 201 * @return true if a response send Redirect have bean call during treatment 202 */ 203 public boolean isSendRedirect() { 204 return _bSendRedirect; 205 } 206 207 /** 208 * Indicate if a response send Redirect have bean call during treatment 209 * @param bSendRedirect true if a response send Redirect have bean call during treatment 210 */ 211 public void setSendRedirect(boolean bSendRedirect) { 212 this._bSendRedirect = bSendRedirect; 213 } 214 }