Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Copyright 2008, 2009, 2010 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry5.corelib.components;
import java.util.Collections;
import java.util.Iterator;
import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Events;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.internal.AjaxFormLoopContext;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.services.TypeCoercer;
import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.ComponentDefaultProvider;
import org.apache.tapestry5.services.Environment;
import org.apache.tapestry5.services.FormSupport;
import org.apache.tapestry5.services.Heartbeat;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
/**
* A special form of the {@link org.apache.tapestry5.corelib.components.Loop} component that adds Ajax support to
* handle adding new rows and removing existing rows dynamically. Expects that the values being iterated over are
* entities that can be identified via a {@link org.apache.tapestry5.ValueEncoder}.
*
* Works with {@link org.apache.tapestry5.corelib.components.AddRowLink} and
* {@link org.apache.tapestry5.corelib.components.RemoveRowLink} components.
*
* The addRow event will receive the context specified by the context parameter.
*
* The removeRow event will receive the client-side value for the row being iterated.
*
* @see EventConstants#ADD_ROW
* @see EventConstants#REMOVE_ROW
*/
@Events(
{ EventConstants.ADD_ROW, EventConstants.REMOVE_ROW })
public class AjaxFormLoop
{
/**
* The element to render for each iteration of the loop. The default comes from the template, or "div" if the
* template did not specify an element.
*/
@Parameter(defaultPrefix = BindingConstants.LITERAL)
@Property(write = false)
private String element;
/**
* The objects to iterate over (passed to the internal Loop component).
*/
@Parameter(required = true, autoconnect = true)
private Iterable source;
/**
* The current value from the source.
*/
@Parameter(required = true)
private Object value;
/**
* Name of a function on the client-side Tapestry.ElementEffect object that is invoked to make added content
* visible. This is used with the {@link FormInjector} component, when adding a new row to the loop. Leaving as
* null uses the default function, "highlight".
*/
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private String show;
/**
* The context for the form loop (optional parameter). This list of values will be converted into strings and
* included in the URI. The strings will be coerced back to whatever their values are and made available to event
* handler methods.
*/
@Parameter
private Object[] context;
/**
* A block to render after the loop as the body of the {@link org.apache.tapestry5.corelib.components.FormInjector}.
* This typically contains a {@link org.apache.tapestry5.corelib.components.AddRowLink}.
*/
@Parameter(value = "block:defaultAddRow", defaultPrefix = BindingConstants.LITERAL)
@Property(write = false)
private Block addRow;
/**
* The block that contains the form injector (it is rendered last, as the "tail" of the AjaxFormLoop). This, in
* turn, references the addRow block (from a parameter, or a default).
*/
@Inject
private Block tail;
/**
* Required parameter used to convert server-side objects (provided from the source) into client-side ids and back.
* A default encoder may be calculated from the type of property bound to the value parameter.
*/
@Parameter(required = true, allowNull = false)
private ValueEncoder