Re: freemarker binding issue .
"Newman, John W" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <721876F56F42304A8CB1CCFF9BFC09BB128EAF21@MSXMBXNSPRD09.acct.upmchs.net> |
I'm not sure that you're getting the split between server side processing and client side code. Freemarker generates the text of the page. Period. That text may or may not be html/javascript. Html/javascript does not know that freemarker exists and more or less vice-versa. The same is true for jsp and most other view generating stacks. The nature of your question isn't really related to freemarker at all, it's more of a general web programming issue.
Whatever you are trying to do can be done very cleanly, but you need to think about it in a different way.
You can put server side code in and around javascript blocks to generate different javascript based on server side state.
[#assign serverSideVariable = true]
<script type="text/javascript">
function dynamicJavascript() {
[#if serverSideVariable]
alert('serverSideVariable was true');
[#else]
alert('serverSideVariable was false');
[/#if]
}
</script>
Will only send
<script type="text/javascript">
function dynamicJavascript() {
alert('serverSideVariable was true');
}
</script>
To the client. The stuff in the square brackets is gone by the time that function gets sent to the client and runs... I don't think this is what you're asking however.. I think your addWccRow is an ajax update request that goes back over to the server-side...
From: Magatapalli, Sarat [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 7:01 AM
To: Daniel Dekany
Cc: [email protected]
Subject: Re: [FreeMarker-user] freemarker binding issue .
Thanks Daniel . I agree with your statement .
Is there way to increment a freemarker variable within a javascript function ?
Example of my FTL :
0) <#assign row=0 />
1) <@spring.bind "wccJobRecords.detailContent[${row}].accentity" />
<input type="text" size = "30" maxlength= "30" id="Entity_0" name="${spring.status.expression}" value="${spring.status.value?default("")}" />
2) Call addWccRow javascript function.
3) function addWccRow(.......){
<#assign row=row+1 />
But when access the row variable in step 1 , it return 0 only , but I am expecting it to incremented .I think this is problem with scope of variables .
I tried with global also it did not work.
I am very new to freemaker , please help me to resolve this issue .
Regards,
Sarat
-----Original Message-----
From: Daniel Dekany [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 4:09 PM
To: Magatapalli, Sarat
Cc: [email protected]
Subject: Re: [FreeMarker-user] freemarker binding issue .
Tuesday, August 2, 2011, 7:38:52 AM, Magatapalli, Sarat wrote:
> One more question :
>
> Can I use Javascript variable in a FREEMARKER expression
>
> Example :
> <script language="javascript">
>
> Var row=1;
> ${report(row)}
The question doesn't make sense this way. FreeMarker runs on the server, generates the HTML page that has no FreeMarker markup in it anymore, sends it to the client computer, then the JavaScript runs on the client computer in the Web browser.
> </script>
> I tried use it but it failed , any other option to do ?
> -----Original Message-----
> From: Daniel Dekany [mailto:[email protected]]
> Sent: Monday, August 01, 2011 4:04 PM
> To: Magatapalli, Sarat
> Cc: [email protected]
> Subject: Re: [FreeMarker-user] freemarker binding issue .
>
> Wrong mailing list I suppose. It sounds like a Spring question.
> Anyway, I don't know Spring MVC Controller, but if the name of those
> repeated fields are the same, certainly you should just receive an
> array or List instead of a single value, so maybe you should declare
> the target bean property(?) as such.
>
>
> Monday, August 1, 2011, 9:21:17 AM, Magatapalli, Sarat wrote:
>
>> Team ,
>>
>> I have question/issue with freemarker binding . As per our
>> requirement I need to insert a NEW ROW in a table when the user clicks on "ADD NEW" button .
>>
>> Step1 : So when the user clicks on "Add MORE" button I inserting a
>> new row within a table , I am handling this using javascript Step 2:
>> When user clicks on the submit button , I Need to send the values
>> entered by user to my Controller (Spring MVC Controller) .
>>
>> So how can binding the values to controller dynamically ?
>>
>> My page looks like below :
>>
>> Please help me to resolve this issue ASAP .
>> Regards,
>> Sarat
>
> --
> Best regards,
> Daniel Dekany
>
> This message w/attachments (message) is intended solely for the use of
> the intended recipient(s) and may contain information that is
> privileged, confidential or proprietary. If you are not an intended
> recipient, please notify the sender, and then please delete and
> destroy all copies and attachments, and be advised that any review or
> dissemination of, or the taking of any action in reliance on, the
> information contained in or attached to this message is prohibited.
> Unless specifically indicated, this message is not an offer to sell or
> a solicitation of any investment products or other financial product
> or service, an official confirmation of any transaction, or an
> official statement of Sender. Subject to applicable law, Sender may
> intercept, monitor, review and retain e-communications (EC) traveling
> through its networks/systems and may produce any such EC to
> regulators, law enforcement, in litigation and as required by law.
> The laws of the country of each sender/recipient may impact the
> handling of EC, and EC may be archived, supervised and produced in
> countries other than the country in which you are located. This
> message cannot be guaranteed to be secure or free of errors or
> viruses. Attachments that are part of this EC may have additional
> important disclosures and disclaimers, which you should read. By
> messaging with Sender you consent to the foregoing.
--
Best regards,
Daniel Dekany
________________________________
This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited.
Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law.
The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. By messaging with Sender you consent to the foregoing.
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user