Limit number of characters displayed in XML invoice report - invoice

I need to limit number of displayed characters in Invoice report (pdf version) for intrastat_transaction_id to something like 20 characters.
This is the code I use to display it
<td class="text-right">
<span t-field="line.intrastat_transaction_id" />
</td>
Tried to limit it using t-options but it didn't work - like this
<td class="text-right" t-options="{'size': '20'}">
<span t-field="line.intrastat_transaction_id" />
</td>
Can it be limited in XML?

Related

I tried using th:remove="all-but-first" in thymeleaf but it didn't work

<td th:remove="all-but-first">
<span th:each="groups : ${userView.user.groupMemberships}">
<span th:text="${groups.group.name}"></span>;
</span>
</td>
I was trying to display the first two rows returned in th:each, so I tried displaying just the first row at first and it didn't work.
How do you display just the first row and also what should we do if we want to display just the first two or three rows in th:each?
The attribute th:remove is used for removing prototyping generated tags.
As an example:
<table th:remove="all-but-first">
<tr th:each="user : ${users}">
<td th:text="${user.name}">John Apricot</td>
</tr>
<tr>
<td>Martha Apple</td>
</tr>
<tr>
<td>Frederic Orange</td>
</tr>
</table>
This means that will remove the second and third tr, leaving only the tr used for iteration. More details here.
So if you only want to display the first element of your collection, there is no need to perform the iteration, you could simply access it by index (or even key if it's a map).
Example:
<td>
<span th:text="${userView.user.groupMemberships[0].group.name}"></span>
</td>
Displayed the first two elements of my collection and then gave a see more option to view the rest of the elements
<td>
<span th:each="groups,itrStatus : ${userView.user.groupMemberships}">
<span th:if="${itrStatus.count < 3}">
<span th:if="${itrStatus.count == 2}">,</span>
<span th:text="${groups.group.name}"></span>
</span>
<span th:if="${itrStatus.count == 3}">
, See more
</span>
</span>
</td>

JSoup to extract particular block from multiple block

I'm new to JSoup and my question here is how do I extract particular text from multiple blocks that share the same class and attributes?
For example here I want to extract the information on 3rd row of the HTML. How do I specified on my JSoup code to extract the information on 3rd row?
<tr>
<td align="center" colspan="2" class="maintitle">Active Stats</td>
</tr>
<tr>
<td class="row2" valign="top"><b>User's local time</b></td>
<td class="row1">Oct 22 2013, 07:23 PM</td>
</tr>
<tr>
<td class="row2" width="30%" valign="top"><b>Total Cumulative Posts</b></td>
<td width="70%" class="row1"><b>4</b>
<br />( 0 posts per day / 0.00% of total forum posts )
</td>
</tr>
Use the CSS-selector syntax to specify what row to select.
Element e = doc.select("tr:eq(2) td.row2").first();
System.out.println(e.text());
will result in
Total Cumulative Posts
A tip is to at least look through the Jsoup documentation before asking questions.
All this can easily be found in the API.
Jsoup - Use selector syntax

parsing an auto generated html file

<tr bgcolor="#FFFFFF">
<td>
<div align="center">
<font face="Arial" size="2">1</font>
</div>
</td>
<td>
<div align="left">
<font face="Arial" size="2">
<a href="displayCompany.php?name=AAMRATECH " target="_self" class="ab1">AAMRATECH
</a>
</font>
</div>
</td>
i have an html file like this. from where i want to retrieve the company name, share price and other values. there isn't any id or name attribute to retrieve this information easily. can you suggest me how to do this?
N.B. i want to use javascript/ jquery / php framework.
In general, seeing you dont say anything about a language or a more specific situation, you can use XPath to select the values you want.

Struts2 s:label issue

We need to display only 1 of the labels depending on condition. This is done through Javascript. That works fine, but the issue is we get a 508 compliant error saying 1 form element has 2 labels. The issue is with "for" in the table. Removing it also shows a 508 error. I tired to change the second label for to for="org.dateOfReg", but still the same. Is there a way to have only 1 label and pass the "for" and "name" values dynamically from javascript? Or is there any other option? Please help. Appreciate it a lot.
<tr id="showDates">
<td id="TypeDate1"><s:label for="dateOfReg" name="dateofReg" value="Date of Interest" /><span class="required" >*</span> :</td>
<td id="TypeDate2"><s:label for="dateOfReg" name="dateofReg" value="Date of Completion" /><span class="required" >*</span> :</td>
<td id="typeDatePick">
<sj:datepicker showButtonPanel="true" id="dateOfReg" name="org.dateOfReg" displayFormat="mm/dd/yy" label="Date of Interest" changeMonth="true" changeYear="true" size="7"/>
</td>
</tr>
Thanks
Harry
Here is what you can do to resolve this. Just have one label and change its innerHTml using JavaScript instead of hiding the label.
<tr id="showDates">
<td id="TypeDateLabel"><s:label for="dateOfReg" name="dateofReg" value="Date of Interest" /><span class="required" >*</span> :</td>
<td id="typeDatePick">
<sj:datepicker showButtonPanel="true" id="dateOfReg" name="org.dateOfReg" displayFormat="mm/dd/yy" label="Date of Interest" changeMonth="true" changeYear="true" size="7"/>
</td>
</tr>
<script language="javascript">
function TriggerToChangeLabel(triggerCondition)
{
if (triggerCondition)
$("dateOfReg").innerHtml = "Date of Interest";
else
$("dateOfReg").innerHtml = "Date of Completion";
}
</script>
But keep in mind that even though it makes the code 508 compliant; Dynamically changing the label text goes against the spirit of the accessibility. Better way to implement the same is it to have two date fields ("Date of Interest" and "Date of Completion"). Upon submission enforce "required" edit on one of the field based on the condition you have for the label change.

Struts 2 select tag - Using the tag (with the same list) multiple times on a page does not work

I need to be able to use the same drop down list multiple times on a page. The first time i use the 'list' on the select tag, it works fine. The same list does not populate the second select tag i use it on. Here are the details.
In the action class, i populate the ArrayList containing values i need to populate the select tag.
setNames(new SomeDAO().getNames());
In the JSP
<s:select list="names"
id="nameList"
listKey="nameId"
listValue="userName"
/>
This select list populates just fine. If I use the following select tag on the same page (using the same list), it fails to print.
<s:select list="names"
id="rName"
listKey="nameId"
listValue="userName" />
If i replace the 'list' above with #{'test':'test'} (hardcoded list), the tag shows up fine. Looks like the property i set in the Action is getting cleared after the first use. Is that whats happening or am i doing something wrong? I get an 'IllegalStateException: Response already committed' error
Edit 1:
setNames() is used in the action method that deals with the JSP page. It is a simple getter function.
In the JSP, here is what i have.
<tr>
<td align="left" class="td-plain">Add New:</td>
<td class="td-plain">
<s:select list="names"
id="addNameID"
name="addUserNameID"
listKey="reinsId"
listValue="reinsName"
headerKey=""
headerValue="--User Name--"
/>
</td>
<td class="td-plain"><input id="addTreatyNumber" type="text" /></td>
<td class="td-plain"><input id="addReinsPercentage" type="text" /></td>
<td class="td-plain"><input id="addFlatDollarRetentionAmt" type="text" /></td>
<td class="td-plain">
<%if(finance){ %>
<input type="button" class="greyButton" value="Add" onclick="addReinsInfo()"/>
<%}else{ %>
None
<%} %>
</td>
</tr>
and then later down on that page, i have
<tr id='<s:property value="caseGroupId"/>:<s:property value="treatyId"/>'>
<td class="td-plain"><input type='checkbox' id='<s:property value="caseGroupId"/>:<s:property value="treatyId"/>'/></td>
<td class="td-plain">
<s:select list="names"
id="rName"
name="dName"
listKey="reinsId"
listValue="reinsName"
headerKey=""
headerValue="--User Name--"
/>
</td>
<td class="td-plain_"><s:textfield id="tNumber" value="%{treatyNumber}"/></td>
<td class="td-plain_"><s:textfield id="tPercentage" value="%{reinspercentage}"/></td>
<td class="td-plain_"><s:textfield id="rAmount" value="%{flatDollarRetentionAmt}"/></td>
<td class="td-plain"><input type="button" value="Delete" class="greyButton"/></td>
</tr>
If I change the 'list' in the second tag to
list="#{'Test':'Test'}"
the tag shows up fine. Please let me know if i can provide any further info.
Edit 2: I was able to get this to work by setting the drop down list values to the session.
As asked by #Dave and #Quaternion, post the relevant Java/JSP code.
But until then... I've noted that you are not using name attribute in Struts Selects;
while you can refer multiple times from different tags to the same source (the list attribute), to populate the Select from the same list of objects, you should instead specify a different name for each one, to define which variable (sent back to the Action) contains the selected value of which Select;
this may not be the answer to the current question but it will show up to you soon.

Resources