This should get you close. fyi, I wrote this in the email client and
has not been tested.


//This can be made much more dynamic by passing in a json object
rather than using fieldId1, fieldId2 etc. however I'm just
demonstrating
//how you can pass these values into your mixin.
<t:submit t:mixins="confirm" t:message="yourMessage"
t:fieldId1="literal:broj" t:fieldId2="literal:datum">Delete
item</t:actionlink>


Create this mixin and add it to your java mixins package.

@Import(library = "context:js/confirm.js")
public class Confirm {

        @Parameter(defaultPrefix = BindingConstants.LITERAL)
        private String fieldId1;

        @Parameter(defaultPrefix = BindingConstants.LITERAL)
        private String fieldId2;


@Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.LITERAL
)
private String message;

@Inject
private JavaScriptSupport js;

@InjectContainer
private ClientElement element;

/**
* Add script.
*/
@AfterRender
public void afterRender() {
js.addInitializerCall("confirmation", new JSONObject("id", this.element.
getClientId(), "message", this.message, "fieldId1", this.fieldId1,
"fieldId2", this.fieldId2));
}
}


Add the following code to a file called confirm.js and add it to your
js package. js/confirm.js

(function ($){
T5.extendInitializers(function(){
function confirmation(spec){
$("#"+spec.id).bind("click", function(e){

//This reads the field values. Id's may be a bit dangerous if your doing
something
//where tapestry may dynamically generate them. 5.4 contributes custom
attributes
//for validation rather than id's which will address the issue of dynamic
id generation.
var field1 = $("#" + spec.fieldId1).val();
var field2 = $("#" + spec.fieldId2).val();

//you will need to create some business logic to handle empty values.

//Generate message example
var message = spec.message + " " + field1 + " " + field2;

if(!confirm(message))
e.preventDefault();
});
}
return { confirmation : confirmation}
});
}) (jQuery);


On Sun, Oct 19, 2014 at 2:20 PM, George Christman <gchrist...@cardaddy.com>
wrote:

> there is no code posted
>
> On Sun, Oct 19, 2014 at 2:14 PM, Name Surname <wintertime0...@outlook.com>
> wrote:
>
>> I made a jquery script that listens for change on every single field. It
>> produces exactly what I wanted, but that's not what I needed. I wanted to
>> implement it using Tap for better understanding how Tap deals with JS.
>> Anyway, here is a code for it:
>>
>>
>>
>>             Crear  Fracciones
>>             Para el sorteo:
>>             Fecha:
>>
>>
>>
>>
>>
>>
>> Confirmar
>>
>>
>
>
>
>
> --
> George Christman
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York
>
>


-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York

Reply via email to