XFA Forms - checksum for the <form> tag - itext7

I'm filling some XFA Forms. Those forms have a template section, a data section, and a form section, which is the merging of the other two. The form tag has a "checksum" attribute, something like this:
<form xmlns="http://www.xfa.org/schema/xfa-form/2.8/" checksum="igN4bJAPtFedO8QmvxpYOT1U9p8=">
I'd like to know how to calculate that checksum, because if it's not correct, Adobe Reader won't pick up the changes to the section. Does anybody know the algorithm for calculating that checksum?
Thanks,
Martín.

Related

Adding labels to explorations data in GA4?

Is it possible to add an arbitrary label to a GA4 exploration?
For example I am tracking outbound link clicks for phone numbers. I would like to add a short description to each number.
I was thinking something like if Link URL equals 'tel: xx xxxx xxx' a label would say 'city office'. Any ideas on this?
Well... You have GTM tag added to your question. This implies that you're ok having a GTM solution.
Well, in GTM, find the tag that fires on the phone clicks, add a custom event property to the tag that would contain the description of the numbers, make a custom JS (CJS) or a look up table (LUT) or better a regex LUT, and map your numbers to descriptions.
Then go to GA and register that event property as a custom dimension. Done.
You could also override the link url dimension in GTM with a CJS var that would generate descriptions in the same dimension, but it's not a good idea to override default dimensions unless you're confident about what you're doing.
GA4 has capabs to modify event properties, but it's extremely basic and won't be able to change properties based on their values. Also, it's a bad idea to have data modification logic in GA. It's best to contain all data modification logic in one place whenever you can help it.

How to conditionally add a class to a Magnolia component template based on the presence of another Component?

I would like to apply a class to my title component in Magnolia only if the content editors have chosen to add the subtitle component to a page. Example of what I am trying to do below:
[#assign subtitle = "somehow get a reference to the subtitle component"]
[#assign subtitleExists = subtitle?has_content]
<div class="title ${subtitleExists?then('removePadding','')}">
${model.render('titleCopy')!}
</div>
Is this possible? I am happy to add more information to help clarify what I am trying to do here if needed. Thanks!
Components are atomic, hence they normally don't see each other and can't influence each other. That would be job of the area grouping the components or parent component or the page itself.
That said, if the structure of the page and of your templates doesn't allow you any other solution, you might set some flag via request attribute in subtitle component and then check for the existence of said flag in your component.
Something along the lines of ctx.setAttribute("subtitleExists", true, 1) on one side and ctx.getAttribute("subtitleExists") on the other side. 1 stands for the local (request) scope for the attribute.

Create page division / format page?

I need to create a page division in Alloys XML, like a <div> tag in HTML
Basically it needs to be able to be variable size, have attributes like font, colour, border ETC and most importantly it needs to have sub tags such as label and button inside
I've tried using sperate views from this and requiring them into the current window. I've also tried using modules, but I'm not sure if I did it correctly.
My question is, what would be the best way to go around this?
You can create a Widget for this: https://wiki.appcelerator.org/display/guides2/Alloy+Widgets
It is basically a reusable component which you can pass parameters into and it has a own controller, style and view file.
In your XML file you can use it like this:
<Widget src="foo" name="button"/>

Resizing/Scaling images in a view by setting custom CSS width

Problem
I'm doing some maintenance and changes on a Drupal site, but I'm not an expert. My problem is the following. I have a view that produces an HTML table by fetching some field values and putting them into the table columns. One of these field is an image. Unfortunately each image has a different size (images are uploaded by users), and so the overall table looks ugly. I would like to resize/scale images so that they all have the same width. I know I can use CSS to set the image width to a fixed value, and let the height adjust accordingly:
<img src="..." style="width:70px"/>
Unfortunately I don't know how to make Drupal output this custom HTML when processing my view. Currently the produced HTML looks like this:
<img
class="imagefield imagefield-field_imgsmall"
width="100"
height="39"
alt=""
src="http://www.mysite.org/sites/default/files/foobar.png?1292948397">
and I guess this is produced by one of the view's fields (namely field_imgsmall).
First question is: what is that number after the ? in the src URL? And where does it come from? (Each image has a different number in the corresponding src URL)
What I've tried
I've noticed that in the "edit view" mode, when selecting a field, I can check the option Rewrite the output of this field, and there I can mix HTML and substitution patterns. However, I've seen that one of the substitution patterns that's available to me ([field_imgsmall_fid]) is actually producing the entire HTML above ... so I can't customize it.
What can I do? Am I going in a totally wrong direction?
You should look into the imagecache module, which allows you to resize images (and cache the results, so the resizing process rarely happens).
Here's a walkthrough:
http://2bits.com/articles/drupal-using-imagecache-with-views-and-cck-imagefields.html

Reload the page without submitting it back to the server

the problem I have is that I have two sets of values in a drop down list. If type 'A' is selected I want a text box to be populated with a value from the database and be read only. If Type 'B' is selected the box is to be empty and editable.
My original code is written in jsp/struts and I have sort of achieved this by using
onchange="javascript:submit()" to reload the page, but this has the obvious drawback of saving any changes you have made which means you can't really cancel.
I also have other problems with the serverside validation due to this method.
Is there a way of making a jsp page reload on change, that way I could write javascript to change the way the page looks according to the values held in the session. That way the save/submit function will only be called when the page has properly been filled out and the server side validation will work as designed.
I know that this is something that AJAX is good at doing but I am trying to avoid it if possible.
AJAX is your only other option my friend, unless on the original page load you load all the other possible values of the Text Box so you don't need to go back to the database. Well, you could try putting the text box in an IFRAME, but you will probably run into more problems with that approach than just going with AJAX.
Without AJAX what you are asking is going to be difficult. Another option (which is ugly) is to write out all possible values for the second list box into a data structure like an array or dictionary.
Then write some javascript to get the values from the data structure when the user selects from the first list box. The amount of javascript you will have to write to get this done and to do it correctly in a cross browser way will be much more difficult than simply using AJAX.
Not sure why you'd try to avoid AJAX in today's world, the JS libraries out there today make it so simple it's crazy not to try it out.
I just had to replace a page that was written as Vincent pointed out. I assume at the time it made sense for the app, given the relative size of the data 4 years ago. Now that the app has scaled though, the page was taking upwards of 30 seconds to parse the data structures repeatedly (poorly written JS? maybe).
I replaced all the logic with a very simple AJAX call to a servlet that simply returns a JSON response of values for the 2nd drop down based on what was passed to it and the response is basically instant.
Good luck to ya.
One way is to change the form's action so that you submit the form to a different url than the "save" url. This lets you reload certain aspects of the form and return to the form itself, instead of committing the data.
<script>
function reload() {
document.forms[0].action="reloadFormData.jsp";
document.forms[0].submit();
}
</script>
<form action="saveData.jsp" method="post">
<select id="A" name="B" onchange="reload()"><!-- blah --></select>
<select id="B" name="B"><!-- blah B --></select>
<input type="submit">
</form>
If I understand you correctly, that you want either a dropdown (<select>) or a textfield (<input type="text">) depending on a choice (typically a checkbox or radiobuttons) somewhere above in a form?
I that case you may need to handle the two types of input differently on the server anyway, so why not have both the selectbox and textfield in the area of the form with different names and id and one of them hidden (display = none). Then toggle visibility when the choice changes. On the server you pick eiter the selectbox or textarea input (wich will both be present unless you disable (disabled="disabled") them too, wich I think is uneccesary) depending on the choice input.
Of course if you expect that the user usually just need the text-input, and a few times only, needing a massive list; it would be better to use ajax to retrieve the list. But if it's the other way around (you need the text-field only occationally), as I assumed above, it will be faster to have both present in the initial form.
If the drop down only contain easily generateable data, like years from now to houndreds of years back it could even be much faster (requiring less bandwidth on the server) to generate the data client side using a for loop in Javascript.
I know a taglib that can fit to your problem:
AjaxTags.
I use this taglib in my J2EE projects and it is very simple to integrate it into web applications.
This taglib give you several tags designed to execute AJAX request in your jsp files.
Here is the description of each tags: http://ajaxtags.sourceforge.net/usage.html
The tag which will help you is the ajax:select tag. It allows you to populate a select tag which depends on an other field without reloading the entire jsp page.
If you more informations about it, ask me and i'll try to answer quicky.
Along the lines of what Strindhaug said, but if you need dynamic data:
Could you have the backend write JS into the page, and then the JS would change the form as required? The backend could propagate some variables for descriptions and such, and then the JS could change/update the form accordingly. If you aren't familiar with this, libs like jQuery make things like this easier and more cross-browser than rolling-your-own (at least in my experience).
Aside:
If you're not using AJAX because it was hard to code (as I didn't for a while because my first experience was from scratch and wasn't pretty), as others have said, libs like MooTools and such make it really easy now. Also, there is not shame in using AJAX properly. It has a bad rap because people do stupid things with it, but if you can't simply write premade values into the form or you have to do live look ups, this is one of AJAX's proper uses.

Resources