Hello,

I've got it as exists, her ist he content of my exists.js:

function exists() {
  var file = new java.io.File(cocoon.parameters["test-uri"]);
  if (file.exists()) {
     cocoon.sendPage(cocoon.parameters["exists-uri"];
  } else {
     cocoon.sendPage(cocoon.parameters["non-exist-uri"];
  }
}

Have I forgotten anything?

regards


-----Ursprüngliche Nachricht-----
Von: Upayavira [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 19. September 2003 13:08
An: [EMAIL PROTECTED]
Betreff: Re: AW: AW: File existence

Mustafa Ali, Halgurt wrote:

>Hello,
>
>I did it as you said, but I got this error message:
>
>(Exists is not a function)
>  
>
Note that Javascript is case sensitive. Have you got it as Exists or as 
exists?

>Another question, when I call the Pipeline handling, I don't have just ID as 
>parameter, even more, how can I pass these parameters to the non-exists pipeline? 
>
You should be able to get at the request parameter inside the non-exists 
pipeline just as in any other, e.g. with <map:parameter name="filename" 
value="{request-param:id}.xml"/>

Regards, Upayavira

>Here is my pipelines:
>
><map:flow language="javascript">
>  <map:script src="flow/exists.js"/>
>  </map:flow>
> <map:pipelines>
> <map:pipeline>
>   <map:match pattern="handling">
>     <map:call function="exists">
>     <map:parameter name="test-uri" value="context://{request-param:ID}.xml"/>
>     <map:parameter name="exists-uri" value="exists"/>
>     <map:parameter name="non-exists-uri" value="non-exists"/>
>     </map:call>
>     </map:match>
>  </map:pipeline>
>  <map:pipeline>
>   <map:match pattern="exists">
>   <map:generate type="file" src="{request-param:ID}.xml"/>
>       <map:transform type="xslt" src="form3data.xsl">
>       <map:parameter name="use-request-parameters" value="true"/>
>    </map:transform>
>    <map:serialize type="html"/>
></map:match>
>   </map:pipeline>
>   <map:pipeline>
>   <map:match pattern="non-exists">
><map:generate type="file" src="default.xml"/>
>       <map:transform type="xslt" src="form2data.xsl">
>       <map:parameter name="use-request-parameters" value="true"/>
>    </map:transform>
>    <map:transform type="write-source">
>    <map:parameter name="use-request-parameters" value="true"/>
>    </map:transform>
>       <map:transform type="xslt" src="form2html.xsl" mime-type="text/xml">
>    <map:parameter name="use-request-parameters" value="true"/>
>    </map:transform>
>    <map:serialize type="html"/>
></map:match>
>
>-----Ursprüngliche Nachricht-----
>Von: Upayavira [mailto:[EMAIL PROTECTED] 
>Gesendet: Freitag, 19. September 2003 11:08
>An: [EMAIL PROTECTED]
>Betreff: Re: AW: File existence
>
>You seem to be having a lot of trouble with this. Have you considered 
>using flow? With the below, if the file exists, the pattern="exists" 
>pipeline will be shown, otherwise the pattern="non-existent" pipeline 
>will be shown.
>
><map:match pattern="page">
>  <map:call function="exists">
>   <map:parameter name="test-uri" value="context://{request-param:ID}.xml"/>
>    <map:parameter name="exist-uri" value="exists"/>
>    <map:parameter name="non-exist-uri" value="non-existent"/>
>  </map:call>
></map:match>
>
><map:match pattern="exists">
>  whatever
></map:match>
>
><map:match pattern="non-existent">
>  whatever
></map:match>
>
>In your sitemap, just before the <map:pipelines> element:
>  <map:flow language="javascript">
>    <map:script src="flow/exists.js"/>
>  </map:flow>
>
>Create a file called flow/exists.js:
>
>function exists() {
>  var file = new java.io.File(cocoon.parameters["test-uri"]);
>  if (file.exists()) {
>     cocoon.sendPage(cocoon.parameters["exists-uri"];
>  } else {
>     cocoon.sendPage(cocoon.parameters["non-exist-uri"];
>  }
>}
>
>HTH. Regards, Upayavira
>
>Mustafa Ali, Halgurt wrote:
>
>  
>
>>Oh, you are right, I changed it, but the pipeline still choose the second part, no 
>>matter whether the file exists or not, it ignores the <act>...</act> part, do you 
>>have an Idea what is perhaps wrong?
>>
>>Thanks,
>>Halgurt
>>PS: I am a Kurd and my first name is Halgurt, we don't have surnames, Mustafa is my 
>>father and Ali my Grandfather.
>>
>>-----Ursprüngliche Nachricht-----
>>Von: Olivier Billard [mailto:[EMAIL PROTECTED] 
>>Gesendet: Freitag, 19. September 2003 10:02
>>An: [EMAIL PROTECTED]
>>Betreff: Re: File existence
>>
>>Hi Halgurt (I'm french and didn't manage to see what is your name and first name, so 
>>sorry 
>>if i'm wrong),
>>
>>Please check if you *really* didn't wrote {request-parameter:ID} instead of 
>>{request-param:ID}, because the error seem to point a mistake of this type...
>>see :
>>cause: org.apache.avalon.framework.component.ComponentException: *input-modules*: 
>>ComponentSelector could not find the component for hint [*request-parameter*] (key 
>>[*request-parameter*])
>>
>>-> this should be request-param...
>>
>>--
>>Olivier
>>
>>
>>On 19/09/2003 10:30, Mustafa Ali, Halgurt wrote:
>>
>> 
>>
>>    
>>
>>>Sure, here is it:
>>>
>>>   
>>>
>>>      
>>>
>><snip/>
>>
>> 
>>
>>    
>>
>>>cause: org.apache.avalon.framework.component.ComponentException: input-modules: 
>>>ComponentSelector could not find the component for hint [request-parameter] (key 
>>>[request-parameter])
>>>
>>>
>>>
>>>-----Ursprüngliche Nachricht-----
>>>Von: Olivier Billard [mailto:[EMAIL PROTECTED] 
>>>Gesendet: Freitag, 19. September 2003 09:19
>>>An: [EMAIL PROTECTED]
>>>Betreff: Re: AW: AW: AW: AW: File existence
>>>
>>>Can you send the exact error and the stack trace you got ?
>>>   
>>>
>>>      
>>>
>> 
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to