Create <dsp:input> element dynamically by jquery (ATG)

524 views Asked by At

I'm trying toadd "DSP:input" element to a "dsp:form" after page loaded, using jquery. (I want to set some extra parameters according to the user behavior)

Since DSP input tags add some hidden fields, I cannot append from jquery like usual tags. Also I cannot generate them using Ajax since It doesn't allows to generate it without a surrounded element.

Please help.

Thanks, Buddhika

1

There are 1 answers

0
Vihung On BEST ANSWER

You cannot. Or rather, you can, but it will not have the effect you want.

DSP tags are interpreted on the server at request-processing time. DSP tags never make their way to the browser. The dsp:input tag in the JSP gets translated to a standard HTML input tag by the JSP processor.

By using JQuery to insert a DSP tag into your document, you are doing this on the client, in the browser. This DSP tag will not get processed by the server. And the browser knows nothing about how to render a DSP tag (because it is not HTML).

DSP tags are processed o the server prior to sending out the response to the browser. What you could do, if it makes sense, is render the dsp:input you want in your JSP first, and then use JQuery to remove the corresponding input tag from the HTML form in the situations where you do not need that input.