You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by beya! <an...@jibeya.com> on 2004/11/16 17:30:04 UTC

Re: Cocoon Forms - validating required fields

Mark,
try this:

<?xml version="1.0"?>

<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
<fd:validation>
   	<fd:javascript>
   		var success = true;
   		var password = widget.lookupWidget("password");
   		if (password.value == null) {
   			quantity.setValidationError(new 
Packages.org.apache.cocoon.forms.validation.ValidationError("Please 
enter password", false));
   			success = false;
   		}
   		return success;
   	</fd:javascript>
</fd:validation>

<fd:widgets>
     <fd:field id="password" required="true">
       <fd:label>Enter password:</fd:label>
       <fd:datatype base="string"/>
       <fd:validation>
         <fd:range min="5" max="9">
           <fd:failmessage>Please enter password.</fd:failmessage>
         </fd:range>
       </fd:validation>
     </fd:field>
</fd:widgets>

</fd:form>

regards


Andrew
On 16 Nov 2004, at 17:14, Mark Leicester wrote:

> Hi all,
>
> When a user leaves a required field blank, is there a way to generate a
> custom fd:failmessage for that specific field?
>
> For example: I have two required fields - username and password - both
> required. Say the user enters their username, but leaves the password
> field blank. I get the [general.field-required] message. How can I
> override this with a custom message saying "Enter your password!
> (please)". Must I resort to a custom Javascript handler?
>
> I've been out of active Cocoon development for nine months or so. It's
> great to be back - and to see how far flow and forms have come on. Nice
> work.
>
> Regards,
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


Re: Cocoon Forms - validating required fields

Posted by Mark Leicester <ma...@efurbishment.com>.
Great, thanks!  So am I right in thinking that the answer to "Must I
resort to a custom Javascript handler?" is "yes".

A colleague and I were wondering why "required" is an attribute. If it was
an element instead, then it could contain a <fd:failmessage> too,
potentially avoiding the need for the extra javascript. Any comments?

Thanks for responding so rapidly to a question from someone who absented
himself from the Cocoon community for far too long, blundering about
instead with PHP. It's nice to be back.

Mark

> Mark,
> try this:
>
> <?xml version="1.0"?>
>
> <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
> <fd:validation>
>    	<fd:javascript>
>    		var success = true;
>    		var password = widget.lookupWidget("password");
>    		if (password.value == null) {
>    			quantity.setValidationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError("Please
> enter password", false));
>    			success = false;
>    		}
>    		return success;
>    	</fd:javascript>
> </fd:validation>
>
> <fd:widgets>
>      <fd:field id="password" required="true">
>        <fd:label>Enter password:</fd:label>
>        <fd:datatype base="string"/>
>        <fd:validation>
>          <fd:range min="5" max="9">
>            <fd:failmessage>Please enter password.</fd:failmessage>
>          </fd:range>
>        </fd:validation>
>      </fd:field>
> </fd:widgets>
>
> </fd:form>
>
> regards
>
>
> Andrew
> On 16 Nov 2004, at 17:14, Mark Leicester wrote:
>
>> Hi all,
>>
>> When a user leaves a required field blank, is there a way to generate a
>> custom fd:failmessage for that specific field?
>>
>> For example: I have two required fields - username and password - both
>> required. Say the user enters their username, but leaves the password
>> field blank. I get the [general.field-required] message. How can I
>> override this with a custom message saying "Enter your password!
>> (please)". Must I resort to a custom Javascript handler?
>>
>> I've been out of active Cocoon development for nine months or so. It's
>> great to be back - and to see how far flow and forms have come on. Nice
>> work.
>>
>> Regards,
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How to add processing instruction in XSP?

Posted by Geert Josten <Ge...@daidalos.nl>.
Hi,

I don't think you can do this inside the XSP page, the page is always wrapped in page, head and body 
kind of elements. Quickest fix would be to put an xsl transform step right after the xsp generator 
with a root template like:

<xsl:template match="/">
   <xsl:processing-instruction
     name="mso:application">progid="Excel.Sheet"</xsl:processing-instruction>
   <xsl:copy-of select="."/>
</xsl:template>

Hope this helps..

Cheers

Ilya Vyatkin wrote:

> Hi all!
>  
> I have the XSP page. The xml it generates is then opened in Microsoft Excel.
> How to add such processing instruction in resul xml?
> <?mso-application progid="Excel.Sheet"?>
> 
> I tried to experiment with something like this:
> <xsp:pi target="mso-application">
>   ..
> </xsp:pi>
> But I could generate only <?mso-application ?> this way.
> Moreover i need to place this p.i. right after <?xml version="1.0" ?> in
> result xml!
> 
> Please help.
> 
> Lars
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 

-- 
Geert.Josten@Daidalos.nl
IT-consultant at Daidalos BV, Zoetermeer (NL)

http://www.daidalos.nl/
tel:+31-(0)79-3316961
fax:+31-(0)79-3316464

GPG: 1024D/12DEBB50

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


How to add processing instruction in XSP?

Posted by Ilya Vyatkin <la...@sigent.ru>.
Hi all!
 
I have the XSP page. The xml it generates is then opened in Microsoft Excel.
How to add such processing instruction in resul xml?
<?mso-application progid="Excel.Sheet"?>

I tried to experiment with something like this:
<xsp:pi target="mso-application">
  ..
</xsp:pi>
But I could generate only <?mso-application ?> this way.
Moreover i need to place this p.i. right after <?xml version="1.0" ?> in
result xml!

Please help.

Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org