Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // 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;
 
Generates a client-side hyperlink that submits the enclosing form. If the link is clicked in the browser, the component will trigger an event (selected by default) , just like Submit .
 
 @Events(. + " by default, may be overridden")
 public class LinkSubmit implements ClientElement
 {
    
If true, then no link (or accompanying JavaScript) is written (though the body still is).
 
     @Parameter
     private boolean disabled;

    
The name of the event that will be triggered if this component is the cause of the form submission. The default is "selected".
 
     @Parameter(allowNull = false, defaultPrefix = .)
     private String event = .;

    
Defines the mode, or client-side behavior, for the submit. The default is org.apache.tapestry5.corelib.SubmitMode.NORMAL; clicking the button submits the form with validation. org.apache.tapestry5.corelib.SubmitMode.CANCEL indicates the client-side validation should be omitted (though server-side validation still occurs).

Since:
5.2.0
 
     @Parameter(allowNull = false, defaultPrefix = .)
     private SubmitMode mode = .;

    
If true (the default), then any notification sent by the component will be deferred until the end of the form submission (this is usually desirable). In general, this can be left as the default except when the LinkSubmit component is rendering inside a Loop, in which case defer should be bound to false (otherwise, the event context will always be the final value of the Loop).
 
     @Parameter
     private boolean defer = true;

    
The list of values that will be made available to event handler method of this component when the form is submitted.

Since:
5.2.0
 
     @Parameter
     private Object[] context;
 
     @Inject
     private ComponentResources resources;
 
     @Inject
 
     @Environmental
     private FormSupport formSupport;
 
     @Environmental
     private Heartbeat heartbeat;
 
     @Inject
    private Request request;
    @SuppressWarnings("unchecked")
    private String clientId;
    private static class ProcessSubmission implements ComponentAction<LinkSubmit>
    {
        private final String clientId;
        public ProcessSubmission(String clientId)
        {
            this. = clientId;
        }
        public void execute(LinkSubmit component)
        {
            component.processSubmission();
        }
    }
    private void processSubmission(String clientId)
    {
        this. = clientId;
        if (clientId.equals(.getParameter(.)))
        {
            Runnable notification = new Runnable()
            {
                public void run()
                {
                    .triggerEvent();
                }
            };
            if ()
                .defer(notification);
            else
                .defer(notification);
        }
    }
    void beginRender(MarkupWriter writer)
    {
        if (!)
        {
            .store(thisnew ProcessSubmission());
            writer.element("span",
            "id");
            .renderInformalParameters(writer);
        }
    }
    void afterRender(MarkupWriter writer)
    {
        if (!)
        {
            writer.end();
            JSONObject spec = new JSONObject("form".getClientId(), "clientId");
            spec.put("validate" == .);
            .addInitializerCall(."linkSubmit"spec);
        }
    }
    public String getClientId()
    {
        return ;
    }
New to GrepCode? Check out our FAQ X