You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <fm...@gmail.com> on 2008/08/04 11:35:31 UTC
Re: Usability of all tags in taglib.tld for jsp
Hi,
janandith jayawardena schrieb:
> Hi,
>
> Thanks Bertrand.
>
> When I use ,
>
> <sling:include addSelectors="selector" replaceSelectors="replace" />
>
> I get the content of replace.jsp
Point is, that the addSelectors and replaceSelectors are also in fact
mutually exclusive in the sense that addSelectors is ignored if
replaceSelectors is set.
Hence the inclusion of replace.jsp is expected.
>
> and
>
> when I use ,
>
> <sling:include addSelectors="selector"/>
> <sling:include addSelectors="selector" replaceSelectors="replace" />
>
> I get both selector.jsp and replace.jsp content.
Similar here: The first include includes the selector.jsp, while the
second includes replace.jsp for the reasons explained above.
>
> I tried this,
>
> <sling:include addSelectors="selector"/>
> <sling:include flush=true />
> <sling:include addSelectors="selector" replaceSelectors="replace" />
>
> hoping flush will erase initial selector.jsp content but there is no content
> and the program fails.
This is a dangerouse one because of the second line with the "flush"
attribute: The flush attribute says to write the current contents of the
output buffer out to the response (and not erase the buffer as you might
expect). In addition this tag will recursively include the same script
again, which should result in an exception being thrown.
>
> I want to test with all these tags in one html.jsp file. how can I use the
> replaceSelector to replace selector.jsp with replace.jsp.
I do not exactly understand what you are trying to achieve. Do you have
three scripts -- html.jsp, selector.jsp and replace.jsp ? And you
request http://host/something.html and have the html.jsp being called.
Now what is next ?
>
> Also why does the whole script fail when using flush. What is the correct
> way to use it.
Due to a recursive inclusion of itself and the exception bein thrown.
This has nothing to do with the flush attribute but with the include
itself, which just includes the current resource with the same selectors
and extension and therefore resolves to the same script over and over
again until too many scripts are included and an exception is thrown.
Regards
Felix
Re: Usability of all tags in taglib.tld for jsp
Posted by janandith jayawardena <ja...@gmail.com>.
Hi,
Thank you Felix for showing me the correct way to use replaceSuffix. It
works fine :-).
I've also managed to use the resulting output as suggested by Bertrand.
Janandith
On Mon, Aug 11, 2008 at 1:12 PM, Bertrand Delacretaz <bdelacretaz@apache.org
> wrote:
> On Mon, Aug 11, 2008 at 9:33 AM, Felix Meschberger <fm...@gmail.com>
> wrote:
> > ...Create a new script, say suffixtest.jsp which contains the test code:
> >
> > String suffixTest = req.getRequestPathInfo().getSuffix() ;
> > if(suffixTest==null){
> > suffixTest = "Suffix Not Successful";
> > }
> > else{
> > suffixTest = "Suffix Successful";
> > }
> >
> > and which is included by suffix.jsp as
> >
> > <sling:include replaceSelectors="suffixtest" reaplceSuffix="/a.b" />...
>
> Having the included script do
>
> ...
> %>
> The suffix in suffixtest.jsp is '<%=
> req.getRequestPathInfo().getSuffix() %>'
>
> And testing the resulting output in the junit testing code sounds more
> flexible - that would allow suffixtest.jsp to be reused for various
> tests.
>
> -Bertrand
>
Re: Usability of all tags in taglib.tld for jsp
Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Aug 11, 2008 at 9:33 AM, Felix Meschberger <fm...@gmail.com> wrote:
> ...Create a new script, say suffixtest.jsp which contains the test code:
>
> String suffixTest = req.getRequestPathInfo().getSuffix() ;
> if(suffixTest==null){
> suffixTest = "Suffix Not Successful";
> }
> else{
> suffixTest = "Suffix Successful";
> }
>
> and which is included by suffix.jsp as
>
> <sling:include replaceSelectors="suffixtest" reaplceSuffix="/a.b" />...
Having the included script do
...
%>
The suffix in suffixtest.jsp is '<%=
req.getRequestPathInfo().getSuffix() %>'
And testing the resulting output in the junit testing code sounds more
flexible - that would allow suffixtest.jsp to be reused for various
tests.
-Bertrand
Re: Usability of all tags in taglib.tld for jsp
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
Create a new script, say suffixtest.jsp which contains the test code:
String suffixTest = req.getRequestPathInfo().getSuffix() ;
if(suffixTest==null){
suffixTest = "Suffix Not Successful";
}
else{
suffixTest = "Suffix Successful";
}
and which is included by suffix.jsp as
<sling:include replaceSelectors="suffixtest" reaplceSuffix="/a.b" />
Regards
Felix
janandith jayawardena schrieb:
> Hi,
>
> Is there another way this can be done so I can test the functionality for
> replaceSuffix . :)
>
> Janandith.
>
> On Mon, Aug 11, 2008 at 1:06 AM, Felix Meschberger <fm...@gmail.com>wrote:
>
>> Hi,
>>
>> I would assume that the problem is, that the replacement suffix is only
>> available in the included request and not in the including request. Thus,
>> the suffix.jsp script is not expected to see the new suffix.
>>
>> Regards
>> Felix
>>
>>
>> janandith jayawardena schrieb:
>>
>>> Hi,
>>> Thanks Felix. I wrote the test for replaceSelector :).
>>>
>>> The problem now is with replace suffix.
>>>
>>> can you suggest a way for this.
>>>
>>> currently in my test file I have this,
>>>
>>>
>>> Map<String,String> props = new HashMap<String,String>();
>>> string resourceTypeX = "/x";
>>> props.put("sling:resourceType", resourceTypeX);
>>> string contentUrlX = testClient.createNode(HTTP_BASE_URL
>>> +resourceTypeX , props);
>>>
>>> string resourceTypeXQ = resourceTypeX + "/q";
>>> props.clear();
>>> props.put("sling:resourceType", resourceTypeXQ);
>>> string contentUrlQ = testClient.createNode(HTTP_BASE_URL
>>> +resourceTypeXQ, props);
>>> uploadTestScript(resourceTypeXQ,"suffix.jsp","html.jsp");
>>>
>>>
>>> public void testReplaceSuffix() throws Exception {
>>>
>>>
>>> final String content = getContent(contentUrlQ + ".html/a.c",
>>> CONTENT_TYPE_HTML);
>>> System.out.println(content);
>>> // assertTrue("result of flush",content.contains("Flush Successful
>>> becasue commit is true"));
>>> }
>>>
>>>
>>> The "suffix.jsp" file contains the following,
>>>
>>> <%@page session="false"%>
>>> <%@page import="org.apache.sling.api.SlingHttpServletRequest"%>
>>> <%@page import="org.apache.sling.api.resource.Resource"%>
>>> <%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0
>>> "%>
>>>
>>> <sling:defineObjects/>
>>>
>>> <sling:include replaceSuffix="a.b" />
>>>
>>> <%
>>> SlingHttpServletRequest req = (SlingHttpServletRequest) request;
>>> String suffixTest = "" ;
>>> suffixTest = req.getRequestPathInfo().getSuffix() ;
>>>
>>> if(suffixTest==null){
>>> suffixTest = "Suffix Not Successful";
>>> }
>>> else{
>>> suffixTest = "Suffix Successful";
>>>
>>> }
>>>
>>> %>
>>>
>>> This test fails.
>>>
>>>
>>> Also you can have a look at the current test at,
>>>
>>> http://code.google.com/p/sling-scala/source/browse/trunk/sling475/?r=85
>>>
>>> regards,
>>>
>>> Janandith.
>>>
>>>
>>>
>>> On Wed, Aug 6, 2008 at 3:34 AM, Felix Meschberger <fmeschbe@gmail.com
>>>> wrote:
>>> Hi Janandith,
>>>> janandith jayawardena schrieb:
>>>>
>>>> Hi Felix,
>>>>>
>>>>> I do not exactly understand what you are trying to achieve. Do you have
>>>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you >
>>>>> request
>>>>> http://host/something.html and have the html.jsp being called.
>>>>>
>>>>> Now what is next ?
>>>>>
>>>>> Thats what I want to do :).
>>>>>
>>>>> Basically I want a way to write a test for SLING-475 which can test the
>>>>> functionality of flush , replaceSelectors and replaceSuffix in
>>>>> <sling:include /> tag. I'm still confused in finding a way to use these
>>>>> options in sling:include tag.
>>>>>
>>>>> Well, I would assume, that testing the flush would not be that easy ...
>>>> Testing the replaceSelectors would mean being able to tell that the
>>>> correct
>>>> script has been included and for replaceSuffix you would check whether in
>>>> the included script the new suffix is visible.
>>>>
>>>> So in html.jsp you would do:
>>>>
>>>> <sling:include replaceSelectors="selector">
>>>>
>>>> in selector.jsp you could do something like
>>>>
>>>> Hello this is selector.jsp
>>>>
>>>> In the response check you would then see whether selector.jsp is
>>>> contained
>>>> in the response. If replaceSelectors would not work, the response would
>>>> not
>>>> contain the checker string.
>>>>
>>>> Similar tests could be done for the replaceSuffix.
>>>>
>>>> Actually, you probably only need two scripts - html.jsp and selector.jsp.
>>>>
>>>> Hope this helps.
>>>>
>>>> Regards
>>>> Felix
>>>>
>>>>
>>>> Janandith.
>>>>>
>>>>>
>>>>> On Mon, Aug 4, 2008 at 3:05 PM, Felix Meschberger <fmeschbe@gmail.com
>>>>>
>>>>>> wrote:
>>>>>>
>>>>> Hi,
>>>>>
>>>>>> janandith jayawardena schrieb:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>>> Thanks Bertrand.
>>>>>>>
>>>>>>> When I use ,
>>>>>>>
>>>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>>>
>>>>>>> I get the content of replace.jsp
>>>>>>>
>>>>>>> Point is, that the addSelectors and replaceSelectors are also in fact
>>>>>>>
>>>>>> mutually exclusive in the sense that addSelectors is ignored if
>>>>>> replaceSelectors is set.
>>>>>>
>>>>>> Hence the inclusion of replace.jsp is expected.
>>>>>>
>>>>>>
>>>>>> and
>>>>>>
>>>>>>> when I use ,
>>>>>>>
>>>>>>> <sling:include addSelectors="selector"/>
>>>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>>>
>>>>>>> I get both selector.jsp and replace.jsp content.
>>>>>>>
>>>>>>> Similar here: The first include includes the selector.jsp, while the
>>>>>>>
>>>>>> second
>>>>>> includes replace.jsp for the reasons explained above.
>>>>>>
>>>>>>
>>>>>> I tried this,
>>>>>>
>>>>>>> <sling:include addSelectors="selector"/>
>>>>>>> <sling:include flush=true />
>>>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>>>
>>>>>>> hoping flush will erase initial selector.jsp content but there is no
>>>>>>> content
>>>>>>> and the program fails.
>>>>>>>
>>>>>>> This is a dangerouse one because of the second line with the "flush"
>>>>>>>
>>>>>> attribute: The flush attribute says to write the current contents of
>>>>>> the
>>>>>> output buffer out to the response (and not erase the buffer as you
>>>>>> might
>>>>>> expect). In addition this tag will recursively include the same script
>>>>>> again, which should result in an exception being thrown.
>>>>>>
>>>>>>
>>>>>> I want to test with all these tags in one html.jsp file. how can I use
>>>>>>
>>>>>>> the
>>>>>>> replaceSelector to replace selector.jsp with replace.jsp.
>>>>>>>
>>>>>>> I do not exactly understand what you are trying to achieve. Do you
>>>>>>> have
>>>>>>>
>>>>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you
>>>>>> request
>>>>>> http://host/something.html and have the html.jsp being called.
>>>>>>
>>>>>> Now what is next ?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Also why does the whole script fail when using flush. What is the
>>>>>>
>>>>>>> correct
>>>>>>> way to use it.
>>>>>>>
>>>>>>> Due to a recursive inclusion of itself and the exception bein thrown.
>>>>>>>
>>>>>> This
>>>>>> has nothing to do with the flush attribute but with the include itself,
>>>>>> which just includes the current resource with the same selectors and
>>>>>> extension and therefore resolves to the same script over and over again
>>>>>> until too many scripts are included and an exception is thrown.
>>>>>>
>>>>>> Regards
>>>>>> Felix
>>>>>>
>>>>>>
>>>>>>
>
Re: Usability of all tags in taglib.tld for jsp
Posted by janandith jayawardena <ja...@gmail.com>.
Hi,
Is there another way this can be done so I can test the functionality for
replaceSuffix . :)
Janandith.
On Mon, Aug 11, 2008 at 1:06 AM, Felix Meschberger <fm...@gmail.com>wrote:
> Hi,
>
> I would assume that the problem is, that the replacement suffix is only
> available in the included request and not in the including request. Thus,
> the suffix.jsp script is not expected to see the new suffix.
>
> Regards
> Felix
>
>
> janandith jayawardena schrieb:
>
>> Hi,
>> Thanks Felix. I wrote the test for replaceSelector :).
>>
>> The problem now is with replace suffix.
>>
>> can you suggest a way for this.
>>
>> currently in my test file I have this,
>>
>>
>> Map<String,String> props = new HashMap<String,String>();
>> string resourceTypeX = "/x";
>> props.put("sling:resourceType", resourceTypeX);
>> string contentUrlX = testClient.createNode(HTTP_BASE_URL
>> +resourceTypeX , props);
>>
>> string resourceTypeXQ = resourceTypeX + "/q";
>> props.clear();
>> props.put("sling:resourceType", resourceTypeXQ);
>> string contentUrlQ = testClient.createNode(HTTP_BASE_URL
>> +resourceTypeXQ, props);
>> uploadTestScript(resourceTypeXQ,"suffix.jsp","html.jsp");
>>
>>
>> public void testReplaceSuffix() throws Exception {
>>
>>
>> final String content = getContent(contentUrlQ + ".html/a.c",
>> CONTENT_TYPE_HTML);
>> System.out.println(content);
>> // assertTrue("result of flush",content.contains("Flush Successful
>> becasue commit is true"));
>> }
>>
>>
>> The "suffix.jsp" file contains the following,
>>
>> <%@page session="false"%>
>> <%@page import="org.apache.sling.api.SlingHttpServletRequest"%>
>> <%@page import="org.apache.sling.api.resource.Resource"%>
>> <%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0
>> "%>
>>
>> <sling:defineObjects/>
>>
>> <sling:include replaceSuffix="a.b" />
>>
>> <%
>> SlingHttpServletRequest req = (SlingHttpServletRequest) request;
>> String suffixTest = "" ;
>> suffixTest = req.getRequestPathInfo().getSuffix() ;
>>
>> if(suffixTest==null){
>> suffixTest = "Suffix Not Successful";
>> }
>> else{
>> suffixTest = "Suffix Successful";
>>
>> }
>>
>> %>
>>
>> This test fails.
>>
>>
>> Also you can have a look at the current test at,
>>
>> http://code.google.com/p/sling-scala/source/browse/trunk/sling475/?r=85
>>
>> regards,
>>
>> Janandith.
>>
>>
>>
>> On Wed, Aug 6, 2008 at 3:34 AM, Felix Meschberger <fmeschbe@gmail.com
>> >wrote:
>>
>> Hi Janandith,
>>>
>>> janandith jayawardena schrieb:
>>>
>>> Hi Felix,
>>>>
>>>>
>>>> I do not exactly understand what you are trying to achieve. Do you have
>>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you >
>>>> request
>>>> http://host/something.html and have the html.jsp being called.
>>>>
>>>> Now what is next ?
>>>>
>>>> Thats what I want to do :).
>>>>
>>>> Basically I want a way to write a test for SLING-475 which can test the
>>>> functionality of flush , replaceSelectors and replaceSuffix in
>>>> <sling:include /> tag. I'm still confused in finding a way to use these
>>>> options in sling:include tag.
>>>>
>>>> Well, I would assume, that testing the flush would not be that easy ...
>>>
>>> Testing the replaceSelectors would mean being able to tell that the
>>> correct
>>> script has been included and for replaceSuffix you would check whether in
>>> the included script the new suffix is visible.
>>>
>>> So in html.jsp you would do:
>>>
>>> <sling:include replaceSelectors="selector">
>>>
>>> in selector.jsp you could do something like
>>>
>>> Hello this is selector.jsp
>>>
>>> In the response check you would then see whether selector.jsp is
>>> contained
>>> in the response. If replaceSelectors would not work, the response would
>>> not
>>> contain the checker string.
>>>
>>> Similar tests could be done for the replaceSuffix.
>>>
>>> Actually, you probably only need two scripts - html.jsp and selector.jsp.
>>>
>>> Hope this helps.
>>>
>>> Regards
>>> Felix
>>>
>>>
>>> Janandith.
>>>>
>>>>
>>>>
>>>> On Mon, Aug 4, 2008 at 3:05 PM, Felix Meschberger <fmeschbe@gmail.com
>>>>
>>>>> wrote:
>>>>>
>>>> Hi,
>>>>
>>>>> janandith jayawardena schrieb:
>>>>>
>>>>> Hi,
>>>>>
>>>>>> Thanks Bertrand.
>>>>>>
>>>>>> When I use ,
>>>>>>
>>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>>
>>>>>> I get the content of replace.jsp
>>>>>>
>>>>>> Point is, that the addSelectors and replaceSelectors are also in fact
>>>>>>
>>>>> mutually exclusive in the sense that addSelectors is ignored if
>>>>> replaceSelectors is set.
>>>>>
>>>>> Hence the inclusion of replace.jsp is expected.
>>>>>
>>>>>
>>>>> and
>>>>>
>>>>>> when I use ,
>>>>>>
>>>>>> <sling:include addSelectors="selector"/>
>>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>>
>>>>>> I get both selector.jsp and replace.jsp content.
>>>>>>
>>>>>> Similar here: The first include includes the selector.jsp, while the
>>>>>>
>>>>> second
>>>>> includes replace.jsp for the reasons explained above.
>>>>>
>>>>>
>>>>> I tried this,
>>>>>
>>>>>> <sling:include addSelectors="selector"/>
>>>>>> <sling:include flush=true />
>>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>>
>>>>>> hoping flush will erase initial selector.jsp content but there is no
>>>>>> content
>>>>>> and the program fails.
>>>>>>
>>>>>> This is a dangerouse one because of the second line with the "flush"
>>>>>>
>>>>> attribute: The flush attribute says to write the current contents of
>>>>> the
>>>>> output buffer out to the response (and not erase the buffer as you
>>>>> might
>>>>> expect). In addition this tag will recursively include the same script
>>>>> again, which should result in an exception being thrown.
>>>>>
>>>>>
>>>>> I want to test with all these tags in one html.jsp file. how can I use
>>>>>
>>>>>> the
>>>>>> replaceSelector to replace selector.jsp with replace.jsp.
>>>>>>
>>>>>> I do not exactly understand what you are trying to achieve. Do you
>>>>>> have
>>>>>>
>>>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you
>>>>> request
>>>>> http://host/something.html and have the html.jsp being called.
>>>>>
>>>>> Now what is next ?
>>>>>
>>>>>
>>>>>
>>>>> Also why does the whole script fail when using flush. What is the
>>>>>
>>>>>> correct
>>>>>> way to use it.
>>>>>>
>>>>>> Due to a recursive inclusion of itself and the exception bein thrown.
>>>>>>
>>>>> This
>>>>> has nothing to do with the flush attribute but with the include itself,
>>>>> which just includes the current resource with the same selectors and
>>>>> extension and therefore resolves to the same script over and over again
>>>>> until too many scripts are included and an exception is thrown.
>>>>>
>>>>> Regards
>>>>> Felix
>>>>>
>>>>>
>>>>>
>>
Re: Usability of all tags in taglib.tld for jsp
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
I would assume that the problem is, that the replacement suffix is only
available in the included request and not in the including request.
Thus, the suffix.jsp script is not expected to see the new suffix.
Regards
Felix
janandith jayawardena schrieb:
> Hi,
> Thanks Felix. I wrote the test for replaceSelector :).
>
> The problem now is with replace suffix.
>
> can you suggest a way for this.
>
> currently in my test file I have this,
>
>
> Map<String,String> props = new HashMap<String,String>();
> string resourceTypeX = "/x";
> props.put("sling:resourceType", resourceTypeX);
> string contentUrlX = testClient.createNode(HTTP_BASE_URL
> +resourceTypeX , props);
>
> string resourceTypeXQ = resourceTypeX + "/q";
> props.clear();
> props.put("sling:resourceType", resourceTypeXQ);
> string contentUrlQ = testClient.createNode(HTTP_BASE_URL
> +resourceTypeXQ, props);
> uploadTestScript(resourceTypeXQ,"suffix.jsp","html.jsp");
>
>
> public void testReplaceSuffix() throws Exception {
>
>
> final String content = getContent(contentUrlQ + ".html/a.c",
> CONTENT_TYPE_HTML);
> System.out.println(content);
> // assertTrue("result of flush",content.contains("Flush Successful
> becasue commit is true"));
> }
>
>
> The "suffix.jsp" file contains the following,
>
> <%@page session="false"%>
> <%@page import="org.apache.sling.api.SlingHttpServletRequest"%>
> <%@page import="org.apache.sling.api.resource.Resource"%>
> <%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
>
> <sling:defineObjects/>
>
> <sling:include replaceSuffix="a.b" />
>
> <%
> SlingHttpServletRequest req = (SlingHttpServletRequest) request;
> String suffixTest = "" ;
> suffixTest = req.getRequestPathInfo().getSuffix() ;
>
> if(suffixTest==null){
> suffixTest = "Suffix Not Successful";
> }
> else{
> suffixTest = "Suffix Successful";
>
> }
>
> %>
>
> This test fails.
>
>
> Also you can have a look at the current test at,
>
> http://code.google.com/p/sling-scala/source/browse/trunk/sling475/?r=85
>
> regards,
>
> Janandith.
>
>
>
> On Wed, Aug 6, 2008 at 3:34 AM, Felix Meschberger <fm...@gmail.com>wrote:
>
>> Hi Janandith,
>>
>> janandith jayawardena schrieb:
>>
>>> Hi Felix,
>>>
>>>
>>> I do not exactly understand what you are trying to achieve. Do you have
>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you >
>>> request
>>> http://host/something.html and have the html.jsp being called.
>>>
>>> Now what is next ?
>>>
>>> Thats what I want to do :).
>>>
>>> Basically I want a way to write a test for SLING-475 which can test the
>>> functionality of flush , replaceSelectors and replaceSuffix in
>>> <sling:include /> tag. I'm still confused in finding a way to use these
>>> options in sling:include tag.
>>>
>> Well, I would assume, that testing the flush would not be that easy ...
>>
>> Testing the replaceSelectors would mean being able to tell that the correct
>> script has been included and for replaceSuffix you would check whether in
>> the included script the new suffix is visible.
>>
>> So in html.jsp you would do:
>>
>> <sling:include replaceSelectors="selector">
>>
>> in selector.jsp you could do something like
>>
>> Hello this is selector.jsp
>>
>> In the response check you would then see whether selector.jsp is contained
>> in the response. If replaceSelectors would not work, the response would not
>> contain the checker string.
>>
>> Similar tests could be done for the replaceSuffix.
>>
>> Actually, you probably only need two scripts - html.jsp and selector.jsp.
>>
>> Hope this helps.
>>
>> Regards
>> Felix
>>
>>
>>> Janandith.
>>>
>>>
>>>
>>> On Mon, Aug 4, 2008 at 3:05 PM, Felix Meschberger <fmeschbe@gmail.com
>>>> wrote:
>>> Hi,
>>>> janandith jayawardena schrieb:
>>>>
>>>> Hi,
>>>>> Thanks Bertrand.
>>>>>
>>>>> When I use ,
>>>>>
>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>
>>>>> I get the content of replace.jsp
>>>>>
>>>>> Point is, that the addSelectors and replaceSelectors are also in fact
>>>> mutually exclusive in the sense that addSelectors is ignored if
>>>> replaceSelectors is set.
>>>>
>>>> Hence the inclusion of replace.jsp is expected.
>>>>
>>>>
>>>> and
>>>>> when I use ,
>>>>>
>>>>> <sling:include addSelectors="selector"/>
>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>
>>>>> I get both selector.jsp and replace.jsp content.
>>>>>
>>>>> Similar here: The first include includes the selector.jsp, while the
>>>> second
>>>> includes replace.jsp for the reasons explained above.
>>>>
>>>>
>>>> I tried this,
>>>>> <sling:include addSelectors="selector"/>
>>>>> <sling:include flush=true />
>>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>>
>>>>> hoping flush will erase initial selector.jsp content but there is no
>>>>> content
>>>>> and the program fails.
>>>>>
>>>>> This is a dangerouse one because of the second line with the "flush"
>>>> attribute: The flush attribute says to write the current contents of the
>>>> output buffer out to the response (and not erase the buffer as you might
>>>> expect). In addition this tag will recursively include the same script
>>>> again, which should result in an exception being thrown.
>>>>
>>>>
>>>> I want to test with all these tags in one html.jsp file. how can I use
>>>>> the
>>>>> replaceSelector to replace selector.jsp with replace.jsp.
>>>>>
>>>>> I do not exactly understand what you are trying to achieve. Do you have
>>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you request
>>>> http://host/something.html and have the html.jsp being called.
>>>>
>>>> Now what is next ?
>>>>
>>>>
>>>>
>>>> Also why does the whole script fail when using flush. What is the
>>>>> correct
>>>>> way to use it.
>>>>>
>>>>> Due to a recursive inclusion of itself and the exception bein thrown.
>>>> This
>>>> has nothing to do with the flush attribute but with the include itself,
>>>> which just includes the current resource with the same selectors and
>>>> extension and therefore resolves to the same script over and over again
>>>> until too many scripts are included and an exception is thrown.
>>>>
>>>> Regards
>>>> Felix
>>>>
>>>>
>
Re: Usability of all tags in taglib.tld for jsp
Posted by janandith jayawardena <ja...@gmail.com>.
Hi,
Thanks Felix. I wrote the test for replaceSelector :).
The problem now is with replace suffix.
can you suggest a way for this.
currently in my test file I have this,
Map<String,String> props = new HashMap<String,String>();
string resourceTypeX = "/x";
props.put("sling:resourceType", resourceTypeX);
string contentUrlX = testClient.createNode(HTTP_BASE_URL
+resourceTypeX , props);
string resourceTypeXQ = resourceTypeX + "/q";
props.clear();
props.put("sling:resourceType", resourceTypeXQ);
string contentUrlQ = testClient.createNode(HTTP_BASE_URL
+resourceTypeXQ, props);
uploadTestScript(resourceTypeXQ,"suffix.jsp","html.jsp");
public void testReplaceSuffix() throws Exception {
final String content = getContent(contentUrlQ + ".html/a.c",
CONTENT_TYPE_HTML);
System.out.println(content);
// assertTrue("result of flush",content.contains("Flush Successful
becasue commit is true"));
}
The "suffix.jsp" file contains the following,
<%@page session="false"%>
<%@page import="org.apache.sling.api.SlingHttpServletRequest"%>
<%@page import="org.apache.sling.api.resource.Resource"%>
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
<sling:defineObjects/>
<sling:include replaceSuffix="a.b" />
<%
SlingHttpServletRequest req = (SlingHttpServletRequest) request;
String suffixTest = "" ;
suffixTest = req.getRequestPathInfo().getSuffix() ;
if(suffixTest==null){
suffixTest = "Suffix Not Successful";
}
else{
suffixTest = "Suffix Successful";
}
%>
This test fails.
Also you can have a look at the current test at,
http://code.google.com/p/sling-scala/source/browse/trunk/sling475/?r=85
regards,
Janandith.
On Wed, Aug 6, 2008 at 3:34 AM, Felix Meschberger <fm...@gmail.com>wrote:
> Hi Janandith,
>
> janandith jayawardena schrieb:
>
>> Hi Felix,
>>
>>
>> I do not exactly understand what you are trying to achieve. Do you have
>>>
>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you >
>> request
>> http://host/something.html and have the html.jsp being called.
>>
>> Now what is next ?
>>>
>>
>>
>> Thats what I want to do :).
>>
>> Basically I want a way to write a test for SLING-475 which can test the
>> functionality of flush , replaceSelectors and replaceSuffix in
>> <sling:include /> tag. I'm still confused in finding a way to use these
>> options in sling:include tag.
>>
>
> Well, I would assume, that testing the flush would not be that easy ...
>
> Testing the replaceSelectors would mean being able to tell that the correct
> script has been included and for replaceSuffix you would check whether in
> the included script the new suffix is visible.
>
> So in html.jsp you would do:
>
> <sling:include replaceSelectors="selector">
>
> in selector.jsp you could do something like
>
> Hello this is selector.jsp
>
> In the response check you would then see whether selector.jsp is contained
> in the response. If replaceSelectors would not work, the response would not
> contain the checker string.
>
> Similar tests could be done for the replaceSuffix.
>
> Actually, you probably only need two scripts - html.jsp and selector.jsp.
>
> Hope this helps.
>
> Regards
> Felix
>
>
>> Janandith.
>>
>>
>>
>> On Mon, Aug 4, 2008 at 3:05 PM, Felix Meschberger <fmeschbe@gmail.com
>> >wrote:
>>
>> Hi,
>>>
>>> janandith jayawardena schrieb:
>>>
>>> Hi,
>>>>
>>>> Thanks Bertrand.
>>>>
>>>> When I use ,
>>>>
>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>
>>>> I get the content of replace.jsp
>>>>
>>>> Point is, that the addSelectors and replaceSelectors are also in fact
>>> mutually exclusive in the sense that addSelectors is ignored if
>>> replaceSelectors is set.
>>>
>>> Hence the inclusion of replace.jsp is expected.
>>>
>>>
>>> and
>>>>
>>>> when I use ,
>>>>
>>>> <sling:include addSelectors="selector"/>
>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>
>>>> I get both selector.jsp and replace.jsp content.
>>>>
>>>> Similar here: The first include includes the selector.jsp, while the
>>> second
>>> includes replace.jsp for the reasons explained above.
>>>
>>>
>>> I tried this,
>>>>
>>>> <sling:include addSelectors="selector"/>
>>>> <sling:include flush=true />
>>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>>
>>>> hoping flush will erase initial selector.jsp content but there is no
>>>> content
>>>> and the program fails.
>>>>
>>>> This is a dangerouse one because of the second line with the "flush"
>>> attribute: The flush attribute says to write the current contents of the
>>> output buffer out to the response (and not erase the buffer as you might
>>> expect). In addition this tag will recursively include the same script
>>> again, which should result in an exception being thrown.
>>>
>>>
>>> I want to test with all these tags in one html.jsp file. how can I use
>>>> the
>>>> replaceSelector to replace selector.jsp with replace.jsp.
>>>>
>>>> I do not exactly understand what you are trying to achieve. Do you have
>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you request
>>> http://host/something.html and have the html.jsp being called.
>>>
>>> Now what is next ?
>>>
>>>
>>>
>>> Also why does the whole script fail when using flush. What is the
>>>> correct
>>>> way to use it.
>>>>
>>>> Due to a recursive inclusion of itself and the exception bein thrown.
>>> This
>>> has nothing to do with the flush attribute but with the include itself,
>>> which just includes the current resource with the same selectors and
>>> extension and therefore resolves to the same script over and over again
>>> until too many scripts are included and an exception is thrown.
>>>
>>> Regards
>>> Felix
>>>
>>>
>>
Re: Usability of all tags in taglib.tld for jsp
Posted by Felix Meschberger <fm...@gmail.com>.
Hi Janandith,
janandith jayawardena schrieb:
> Hi Felix,
>
>
>> I do not exactly understand what you are trying to achieve. Do you have
> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you > request
> http://host/something.html and have the html.jsp being called.
>
>> Now what is next ?
>
>
> Thats what I want to do :).
>
> Basically I want a way to write a test for SLING-475 which can test the
> functionality of flush , replaceSelectors and replaceSuffix in
> <sling:include /> tag. I'm still confused in finding a way to use these
> options in sling:include tag.
Well, I would assume, that testing the flush would not be that easy ...
Testing the replaceSelectors would mean being able to tell that the
correct script has been included and for replaceSuffix you would check
whether in the included script the new suffix is visible.
So in html.jsp you would do:
<sling:include replaceSelectors="selector">
in selector.jsp you could do something like
Hello this is selector.jsp
In the response check you would then see whether selector.jsp is
contained in the response. If replaceSelectors would not work, the
response would not contain the checker string.
Similar tests could be done for the replaceSuffix.
Actually, you probably only need two scripts - html.jsp and selector.jsp.
Hope this helps.
Regards
Felix
>
> Janandith.
>
>
>
> On Mon, Aug 4, 2008 at 3:05 PM, Felix Meschberger <fm...@gmail.com>wrote:
>
>> Hi,
>>
>> janandith jayawardena schrieb:
>>
>>> Hi,
>>>
>>> Thanks Bertrand.
>>>
>>> When I use ,
>>>
>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>
>>> I get the content of replace.jsp
>>>
>> Point is, that the addSelectors and replaceSelectors are also in fact
>> mutually exclusive in the sense that addSelectors is ignored if
>> replaceSelectors is set.
>>
>> Hence the inclusion of replace.jsp is expected.
>>
>>
>>> and
>>>
>>> when I use ,
>>>
>>> <sling:include addSelectors="selector"/>
>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>
>>> I get both selector.jsp and replace.jsp content.
>>>
>> Similar here: The first include includes the selector.jsp, while the second
>> includes replace.jsp for the reasons explained above.
>>
>>
>>> I tried this,
>>>
>>> <sling:include addSelectors="selector"/>
>>> <sling:include flush=true />
>>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>>
>>> hoping flush will erase initial selector.jsp content but there is no
>>> content
>>> and the program fails.
>>>
>> This is a dangerouse one because of the second line with the "flush"
>> attribute: The flush attribute says to write the current contents of the
>> output buffer out to the response (and not erase the buffer as you might
>> expect). In addition this tag will recursively include the same script
>> again, which should result in an exception being thrown.
>>
>>
>>> I want to test with all these tags in one html.jsp file. how can I use the
>>> replaceSelector to replace selector.jsp with replace.jsp.
>>>
>> I do not exactly understand what you are trying to achieve. Do you have
>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you request
>> http://host/something.html and have the html.jsp being called.
>>
>> Now what is next ?
>>
>>
>>
>>> Also why does the whole script fail when using flush. What is the correct
>>> way to use it.
>>>
>> Due to a recursive inclusion of itself and the exception bein thrown. This
>> has nothing to do with the flush attribute but with the include itself,
>> which just includes the current resource with the same selectors and
>> extension and therefore resolves to the same script over and over again
>> until too many scripts are included and an exception is thrown.
>>
>> Regards
>> Felix
>>
>
Re: Usability of all tags in taglib.tld for jsp
Posted by janandith jayawardena <ja...@gmail.com>.
Hi Felix,
> I do not exactly understand what you are trying to achieve. Do you have
three scripts -- html.jsp, selector.jsp and replace.jsp ? And you > request
http://host/something.html and have the html.jsp being called.
> Now what is next ?
Thats what I want to do :).
Basically I want a way to write a test for SLING-475 which can test the
functionality of flush , replaceSelectors and replaceSuffix in
<sling:include /> tag. I'm still confused in finding a way to use these
options in sling:include tag.
Janandith.
On Mon, Aug 4, 2008 at 3:05 PM, Felix Meschberger <fm...@gmail.com>wrote:
> Hi,
>
> janandith jayawardena schrieb:
>
>> Hi,
>>
>> Thanks Bertrand.
>>
>> When I use ,
>>
>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>
>> I get the content of replace.jsp
>>
>
> Point is, that the addSelectors and replaceSelectors are also in fact
> mutually exclusive in the sense that addSelectors is ignored if
> replaceSelectors is set.
>
> Hence the inclusion of replace.jsp is expected.
>
>
>> and
>>
>> when I use ,
>>
>> <sling:include addSelectors="selector"/>
>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>
>> I get both selector.jsp and replace.jsp content.
>>
>
> Similar here: The first include includes the selector.jsp, while the second
> includes replace.jsp for the reasons explained above.
>
>
>> I tried this,
>>
>> <sling:include addSelectors="selector"/>
>> <sling:include flush=true />
>> <sling:include addSelectors="selector" replaceSelectors="replace" />
>>
>> hoping flush will erase initial selector.jsp content but there is no
>> content
>> and the program fails.
>>
>
> This is a dangerouse one because of the second line with the "flush"
> attribute: The flush attribute says to write the current contents of the
> output buffer out to the response (and not erase the buffer as you might
> expect). In addition this tag will recursively include the same script
> again, which should result in an exception being thrown.
>
>
>> I want to test with all these tags in one html.jsp file. how can I use the
>> replaceSelector to replace selector.jsp with replace.jsp.
>>
>
> I do not exactly understand what you are trying to achieve. Do you have
> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you request
> http://host/something.html and have the html.jsp being called.
>
> Now what is next ?
>
>
>
>> Also why does the whole script fail when using flush. What is the correct
>> way to use it.
>>
>
> Due to a recursive inclusion of itself and the exception bein thrown. This
> has nothing to do with the flush attribute but with the include itself,
> which just includes the current resource with the same selectors and
> extension and therefore resolves to the same script over and over again
> until too many scripts are included and an exception is thrown.
>
> Regards
> Felix
>