apex:repeat two levels of related lists in a Visualforce page - visualforce

The following works fine for the first level ...
<apex:repeat var="session" value={!Event__c.Sessions__r}">
<apex:outputText value="{!session.Name}"></apex:outputText>
</apex:repeat>
For the second level this is what we tried.
<apex:repeat var="speaker" value="{!Event__c.Sessions__r.Speakers__r}">
<apex:outputText value="{!speaker.Name}"></apex:out>
</apex:repeat>
But there is a syntax error. Is this possible or does it need a controller or extension?

Well first of all It would be better to include the syntax error, to understand the issue.
I tried similar code and found you have a syntax error on your second output text.
<apex:outputText value="{!speaker.Name}"></apex:out>
<apex:outputText value="{!speaker.Name}"></apex:outputText>
Second line is what you are suppose to have.

Related

NReco pdf generator issue

I am getting the exact same error code as this question. I also read the answer to that post but not sure how it'll help in the context of this specific error.
NReco PDF generator works when I omit this line in this html file:
<tr>
<td valign="bottom"><div align="left" class="P ">- Other Receipts</div></td>
<td valign="bottom"><div align="center" class="P ">(36)</div></td>
<td valign="bottom"><div align="right" class="P ">83,00</div></td>
</tr>
If I do include that line I get the (exit code: -1073741819) exception. If I really want to include that line, then I must omit this line of code at the header of the same html file:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
For me this is beyond irrational behavior. I dont see how styling or the content that I add in the html file will cause it to crash.
Can anyone assist me with this?
NReco.PdfGenerator is a .NET wrapper for wkhtmltopdf, and this kind of exception indicates that 'wkhtmltopdf.exe' process is crushed for unknown reason.
This means that you need to check what in wkhtmltopdf causes a crush -- you may do that in the command line, actually. Typical reasons:
CSS border-radius rules in some specific cases may cause a crush
if page margins are defined explicitly and it is not enough space for header or footer content this also may cause wkhtmltopdf crush
Unfortunately only way to find a workaround are experiments, however in most cases workaround is possible.

How to allow multiple select to form:radio buttons that are in loop

Hei,
I ran into a problem with my survey application. I display all questions(6) using c:forEach loop and all of them are displayed on a single page. Using the same loop I also display all the textareas for answers. Everything worked great until I got a stupid idea to add radio buttons with values as an answer input for some questions. My code looks like this:
<c:forEach items="${questions}" var="q">
<p><c:out value="${q.questionText}"></c:out></p>
<c:choose>
<c:when test="${q.questionID !='2' && q.questionID !='6'}">
<form:checkboxes path="answerList" items="${options}"/>
</c:when>
<c:otherwise>
<form:textarea path="answerList" rows="5" cols="40" placeholder="Vasta tähän"></form:textarea>
</c:otherwise>
</c:choose>
</c:forEach>
As it is all in loop so multiplay radio button rows will be displayed (1 per question) And the problem is that I need to get 1 selected answer in each row. I tried to change form:radiobuttons to form:checkboxes and it worked, but then problem is that user can select multiple option per 1 row. Has anybody ran into the same problem and found an answer? Thanx in advance.
Yeah I got it to work. Needed to simply use checkboxes instead of radio buttons and also one tiny javascript that prevent multiple selection in answer row.

Xpath expression with breaks in the middle

I have the following code
<tr>
<td>
F10_12-03_R1200
<br/>
v01.00_Vorgelegt
</td>
</tr>
which i have to access using Xpath.
I've tried using
.//tr/td[contains(text(), 'F10_12-03_R1200')]
Which works but also matches other nodes.
When trying
.//tr/td[contains(text(), 'F10_12-03_R1200') and contains(text(), 'v01.00_Vorgelegt')]
nonthing is coming.
Any hint?
Thanks!
When I change your XPath too:
.//tr/td[contains(., 'F10_12-03_R1200') and contains(., 'v01.00_Vorgelegt')]
It outputs the desired output in Altova XML Spy. I have tested it.
See next screenshot: http://i929.photobucket.com/albums/ad134/markdark81/xpath.png

How can I use Spring MVC "form" tag instead of my "input" tags?

What I have:
I have a generic JSP page that is used throughout my application for displaying certain entities. The code that I am interested in goes like this:
<form:form modelAttribute="object"/>
<core:forEach items="${sections}" var="section" varStatus="itemStat">
<core:forEach items="${section.fields}" var="fieldDef">
<form:input path="${fieldDef.fieldName}"/>
</core:forEach>
</core:forEach>
<form:form>
For each section, and for each field in that section, I have an input having the path fieldName, which is what I want to display from each field.
What I want:
I would like instead of the input to be a simple text, like a label.
What I have tried:
I am most certain that I can do it somehow with <form:label> but I can't really make it work. Making a <form:label path="${fieldDef.fieldName}" /> just tells the browser for which field I need the label, but doesn't get the actual value from it.
I have also tried something like ${object.fieldDef.fieldName}, but in order for this to work I would have to first analyze the value of ${fieldDef.fieldName}, which would give me the name of the column, and then do a ${object.column}, but column being a variable I haven't been able to make this work in any way.
Alternative:
An alternative would be to just make the inputs as disabled and remove the border with CSS, but that would be a dirty way and from what I saw it is also tricky for IE different versions. I am sure that I can handle it directly.
I am a little intrigued by the fact that <form:input path="..."> puts into the input what it finds corresponding to that path (same goes for other form elements), but with label it works different.
So, what I want is basically simple, but I haven't managed to find a way. If someone could shed some light, that would be great. Thanks in advance !
You could look into the spring bind tag. I haven't tried using it before but this may work for you, in place of the input tag
<spring:bind path="fieldDef.fieldName">
${status.value}
</spring:bind>
reference: http://static.springsource.org/spring/docs/1.1.5/taglib/tag/BindTag.html
Instead of
<form:input path="${fieldDef.fieldName}"/>
use
<c:out value="${fieldDef.fieldName}"/>
It would display whatever value is there instead of creating a input field. Hope this helps you. Cheers.
Using the spring form tab, one option would be to use
<form:input disabled="true" path="${fieldDef.fieldName}"/>
To further make it not look like an input you could use CSS to style it to your preference.
Some css styles you could use:
background-color:#EEEEEE;border: 0px solid;
Update:
You could look into the spring bind tag. I haven't tried using it before but this may work for you, in place of the input tag
<spring:bind path="fieldDef.fieldName">
${status.value}
</spring:bind>

Selenium WebDriver and xpath: a more complicated selection

So let's say my structure looks like this at some point:
..........
<td>
[...]
<input value="abcabc">
[...]
</td>
[...]
<td></td>
[...]
<td>
<input id="booboobooboo01">
<div></div> <=======I want to click this!
</td>
.........
I need to click that div, but I need to be sure it's on the same line as the td containing the input with value="abcabc". I also know that the div I need to click (which doesn't have id or any other relevant attribute I can use) is in a td at the same level as the first td, right after the input with id CONTAINING "boo" (dynamically generated, I only know the root part of the id). td's contain nothing relevant I can use.
This is what I tried as far as xpath goes:
//input[#value='abcabc']/../td/input[contains(#id,'boo')]/following-sibling::div
//input[#value='abcabc']/..//td/input[contains(#id,'boo')]/following-sibling::div
None of them worked, of course (element cannot be found).
I want to know if there's a way of selecting that div and how.
EDIT: //input[#value='abcabc']/../../td/input[contains(#id,'boo')]/following-sibling::div is the correct way. This was suggested by the person with the accepted answer. Also note that he offered a slightly different way of doing it. See his answer for details.
Try
//input[#value='abcabc']/ancestor::tr[1]/td/input[contains(#id,'boo')]/following-sibling::div[1]
Note that //input[#value='abcabc']/.. only goes up to the parent <td>, that's why your's did not work.
Another XPath that may work, is a bit more simple:
//input[#id='booboobooboo01']/../div[1]

Resources