Package org.apache.tapestry.form.translator

Examples of org.apache.tapestry.form.translator.DateTranslator


    protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
    {
        PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);

        boolean disabled = isDisabled();
        DateTranslator translator = (DateTranslator) getTranslator();
        Locale locale = getPage().getLocale();
        SimpleDateFormat format = translator.getDateFormat(locale);

        DateFormatSymbols dfs = format.getDateFormatSymbols();
        Calendar cal = Calendar.getInstance(locale);

        String name = getName();
View Full Code Here


   
    public void validate(IFormComponent field, ValidationMessages messages, Object object)
    throws ValidatorException
    {
        Date date = (Date) object;
        DateTranslator translator = (DateTranslator) getFieldTranslator(field, DateTranslator.class);
       
        if (date.before(_minDate))
            throw new ValidatorException(buildMessage(messages, field, translator),
                    ValidationConstraint.TOO_SMALL);
View Full Code Here

    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle,
            FormComponentContributorContext context, IFormComponent field)
    {
        // TODO: This is a little hacky, but validators need to be able to cooperate
        // with translators during client side validation as well
        DateTranslator translator = (DateTranslator) getFieldTranslator(field, DateTranslator.class);
        if (translator == null)
            return;
       
        JSONObject profile = context.getProfile();
       
        context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");");
       
        if (!profile.has(ValidationConstants.CONSTRAINTS)) {
            profile.put(ValidationConstants.CONSTRAINTS, new JSONObject());
        }
        JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS);
       
        accumulateProperty(cons, field.getClientId(),
                new JSONLiteral("[tapestry.form.datetime.isValidDate,{"
                        + "min:"
                        + JSONObject.quote(translator.format(field, context.getLocale(), _minDate))
                        + ","
                        + "format:"
                        + JSONObject.quote(Strftime.convertToPosixFormat(translator.getPattern()))
                        + "}]"));
       
        accumulateProfileProperty(field, profile,
                ValidationConstants.CONSTRAINTS, buildMessage(context, field, translator));
    }
View Full Code Here

    public void validate(IFormComponent field, ValidationMessages messages, Object object)
            throws ValidatorException
    {
        Date date = (Date) object;
        DateTranslator translator = (DateTranslator) getFieldTranslator(field, DateTranslator.class);
       
        if (date.after(_maxDate))
            throw new ValidatorException(buildMessage(messages, field, translator),
                    ValidationConstraint.TOO_LARGE);
       
View Full Code Here

    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle,
            FormComponentContributorContext context, IFormComponent field)
    {
        // TODO: This is a little hacky, but validators need to be able to cooperate
        // with translators during client side validation as well
        DateTranslator translator = (DateTranslator) getFieldTranslator(field, DateTranslator.class);
        if (translator == null)
            return;
       
        JSONObject profile = context.getProfile();
       
        context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");");
       
        if (!profile.has(ValidationConstants.CONSTRAINTS)) {
            profile.put(ValidationConstants.CONSTRAINTS, new JSONObject());
        }
        JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS);
       
        accumulateProperty(cons, field.getClientId(),
                new JSONLiteral("[tapestry.form.datetime.isValidDate,{"
                        + "max:"
                        + JSONObject.quote(translator.format(field, context.getLocale(), _maxDate))
                        + ","
                        + "format:"
                        + JSONObject.quote(Strftime.convertToPosixFormat(translator.getPattern()))
                        + "}]"));
       
        accumulateProfileProperty(field, profile,
                ValidationConstants.CONSTRAINTS, buildMessage(context, field, translator));
    }
View Full Code Here

     * {@inheritDoc}
     */
    protected void renderFormWidget(IMarkupWriter writer, IRequestCycle cycle)
    {
        // dojo dates are in POSIX style formats so we format the value manually
        DateTranslator translator = (DateTranslator) getTranslator();
       
        renderDelegatePrefix(writer, cycle);
       
        // the html output doesn't matter very much as dojo
        // will create an inline input field for us anyways, but we do need
        // a node to reference
        writer.begin("div");
        renderIdAttribute(writer, cycle);
       
        renderDelegateAttributes(writer, cycle);
       
        getValidatableFieldSupport().renderContributions(this, writer, cycle);
       
        renderInformalParameters(writer, cycle);
       
        writer.end();
        renderDelegateSuffix(writer, cycle);
       
        // now create widget parms
        JSONObject json = new JSONObject();
        json.put("inputId", getClientId());
        json.put("inputName", getName());
        json.put("iconAlt", getIconAlt());
        json.put("dateFormat", Strftime.convertToPosixFormat(translator.getPattern()));
        if (getValue() != null)
            json.put("date", DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL,
                    getPage().getLocale()).format(getValue()));
       
        Map parms = new HashMap();
View Full Code Here

     * {@inheritDoc}
     */
    protected void renderFormWidget(IMarkupWriter writer, IRequestCycle cycle)
    {
        // dojo dates are in POSIX style formats so we format the value manually
        DateTranslator translator = (DateTranslator) getTranslator();
       
        renderDelegatePrefix(writer, cycle);
       
        // the html output doesn't matter very much as dojo
        // will create an inline input field for us anyways, but we do need
        // a node to reference
        writer.begin("div");
        renderIdAttribute(writer, cycle);
       
        renderDelegateAttributes(writer, cycle);
       
        getValidatableFieldSupport().renderContributions(this, writer, cycle);
       
        renderInformalParameters(writer, cycle);
       
        writer.end();
        renderDelegateSuffix(writer, cycle);
       
        // now create widget parms
        JSONObject json = new JSONObject();
        json.put("inputId", getClientId());
        json.put("inputName", getName());
        json.put("iconAlt", getIconAlt());
        json.put("dateFormat", Strftime.convertToPosixFormat(translator.getPattern()));
        if (getValue() != null)
            json.put("date", getTranslatedFieldSupport().format(this, getValue()));
       
        Map parms = new HashMap();
        parms.put("clientId", getClientId());
View Full Code Here

{
   
    public void test_Render()
    {
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        DateTranslator translator = new DateTranslator();
        translator.setPattern("hh:mm a");
        ResponseBuilder resp = newMock(ResponseBuilder.class);
       
        IRequestCycle cycle = newMock(IRequestCycle.class);
        IForm form = newMock(IForm.class);
        checkOrder(form, false);
View Full Code Here

     * {@inheritDoc}
     */
    protected void renderFormWidget(IMarkupWriter writer, IRequestCycle cycle)
    {
        // dojo dates are in POSIX style formats so we format the value manually
        DateTranslator translator = (DateTranslator) getTranslator();
       
        renderDelegatePrefix(writer, cycle);
       
        // the html output doesn't matter very much as dojo
        // will create an inline input field for us anyways, but we do need
        // a node to reference
        writer.begin("div");
        renderIdAttribute(writer, cycle);
       
        renderDelegateAttributes(writer, cycle);
       
        getValidatableFieldSupport().renderContributions(this, writer, cycle);
       
        renderInformalParameters(writer, cycle);
       
        writer.print(" ");
       
        writer.end();
        renderDelegateSuffix(writer, cycle);
       
        // now create widget parms
        JSONObject json = new JSONObject();
        json.put("inputId", getClientId());
        json.put("inputName", getName());
        json.put("iconAlt", getIconAlt());
        json.put("displayFormat", translator.getPattern(getPage().getLocale()));
        json.put("saveFormat", translator.getPattern(getPage().getLocale()));
       
        if (getValue() != null) {
            json.put("value", translator.formatRfc3339(getValue()));
        }
       
        json.put("disabled", isDisabled());
       
        Map parms = new HashMap();
View Full Code Here

     * {@inheritDoc}
     */
    protected void renderFormWidget(IMarkupWriter writer, IRequestCycle cycle)
    {
        // dojo dates are in POSIX style formats so we format the value manually
        DateTranslator translator = (DateTranslator) getTranslator();
       
        renderDelegatePrefix(writer, cycle);
       
        // the html output doesn't matter very much as dojo
        // will create an inline input field for us anyways, but we do need
        // a node to reference
        writer.begin("div");
        renderIdAttribute(writer, cycle);
       
        renderDelegateAttributes(writer, cycle);
       
        getValidatableFieldSupport().renderContributions(this, writer, cycle);
       
        renderInformalParameters(writer, cycle);
       
        writer.print(" ");
       
        writer.end();
        renderDelegateSuffix(writer, cycle);
       
        // now create widget parms
        JSONObject json = new JSONObject();
        json.put("inputId", getClientId());
        json.put("inputName", getName());
        json.put("iconAlt", getIconAlt());
        json.put("displayFormat", translator.getPattern(getPage().getLocale()));
        json.put("saveFormat", translator.getPattern(getPage().getLocale()));
       
        if (getValue() != null) {
            json.put("value", translator.formatRfc3339(getValue()));
        }
       
        json.put("disabled", isDisabled());
       
        Map parms = new HashMap();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.form.translator.DateTranslator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.