Fetch a list item to a MultiLine textBox - list

I have a question regarding how to fetch a value from list item to a MultiLine textBox.
I have tried alot. First time it gave the correct data.
and still it gives the correct data however it also fetches the div tags along with the data.
Any thoughts if any please help.
Here is my code:
Register.aspx
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Prerequisite"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtPrerequisite1" runat="server" TextMode="MultiLine" ReadOnly="true"></asp:TextBox>
</td>
</tr>
Register.aspx.cs
string oPrerequisite = null;
SPSite oSPSiteCollection = SPContext.Current.Site;
SPWeb oSPWeb = SPContext.Current.Web;
SPList oSPList1 = oSPWeb.Lists["Scheduled Courses"];
SPListItemCollection oItemCollectionCourse = oSPList1.Items;
foreach (SPListItem ospListItemCourse in oItemCollectionCourse)
{
oPrerequisite = ospListItemCourse["Prerequisite"].ToString();
TxtPrerequisite1.Text = oPrerequisite;
}
The actual out put i am getting is :
<div class="ExternalClassEAA502F55D7B4F9BBA347E2137621D8A"><p> Correct Value is here >div </p></div>
Where as the expected output is:
Correct Value is here
How can I remove the tag from the correct answer so I have only value.

Try SPHttpUtility.ConvertSimpleHtmlToText
TxtPrerequisite1.Text =
SPHttpUtility.ConvertSimpleHtmlToText(oPrerequisite, oPrerequisite.Length);

Related

How can I build a complex e-mail - template plus content saved in a variable - using cfscript instead of cfmail?

This is expanding a bit on a question I asked earlier. Server is CF2016. I'm saving a table of data using savecontent:
savecontent variable = 'mailBody' {
writeOutput('
<table width="99%" style="border-collapse:collapse;width:99%;">
<tr>
<td style="background-color:##09AFFF;color:##FFFFFF;width:30%;padding-left:3px;padding-top:5px;padding-bottom:5px;font-size:12px;font-weight:700;border-bottom:1px solid ##5B5B5B;text-align:left;">Name</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:15%;padding-top:5px;padding-bottom:5px;font-size:12px;font-weight:700;border-bottom:1px solid ##5B5B5B;text-align:center;">Class</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:30%;padding-top:5px;padding-bottom:5px;font-size:12px;text-align:left;font-weight:700;border-bottom:1px solid ##5B5B5B;">City,State,ZIP</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:15%;padding-right:5px;padding-top:5px;padding-bottom:5px;font-size:12px;text-align:left;font-weight:700;border-bottom:1px solid ##5B5B5B;">Amount</td>
</tr>
');
for ( qryPeople in queryPeople ){
writeOutput('
<tr>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#qryPeople.p_first# #qryPeople.p_last#</td>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;text-align:center;">#YEAR(qryPeople.p_graduation)#</td>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#qryPeople.p_city# #qryPeople.p_state#</td>
<td style="font-size:12px;padding-top:3px;padding-bottom:4px;padding-right:5px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#NumberFormat(qryValue.p_value,'99,999')#</td>
</tr>
');
};
writeOutput('
<tr>
<td colspan="5" style="font-size:11px;padding-left:5px;padding-top:5px;padding-right:5px;padding-bottom:7px;background-color:##09AFFF;color:##FFFFFF;font-style:italic;border-bottom:1px solid ##5B5B5B;">footer text</td>
</tr>
</table>
');
};//end savecontent
Works fine through here - I can output the variable mailBody and I see a styled table suitable for HTML email.
We have stock email templates that we use (.htm) files that are stored centrally. I'm trying to inject this content into one of these templates to be sent.
mailerService = new mail();
mailTemplate = fileRead(application.paths.physicalroot & '\email\project1\templates\people.htm');
mailerService.setTo("me#domain.com");
mailerService.setFrom("support#domain.com");
mailerService.setSubject("People Report");
mailerService.setType("html");
mailerService.send(body=mailTemplate);
In the .htm template file I have
<cfoutput>#mailBody#</cfoutput>
And it's giving me exactly that - #mailBody#. In less complex e-mails I have no problem using something like
<cfoutput>Welcome #qryPeople.p_first# #qryPeople.p_last#</cfoutput>
Or accessing other variables set on the cfscript template that drives the e-mail. But I can't figure out why my savecontent variable isn't working as expected.
SOLUTION - previously trying a savecontent include did not work, but that may have been on ACF 2010. This works on ACF2016.
mailerService = new mail();
savecontent variable="mailTemplate" {
include variables.templatePath & '\email\project1\templates\people.htm';
};
mailerService.setTo("me#domain.com");
People.htm is included and the other savecontent (mailbody) is rendered in the e-mail. Now to figure it out using the newer cfmail() script...
If you only have one "block" to be evaluated, I'd just replace it using a string function:
mailTemplate = fileRead(application.paths.physicalroot & '\email\project1\templates\people.htm');
mailTemplate = replaceNoCase(mailTemplate, "##mailBody##", mailBody, "one");
// continue with mailerService.* methods
Another option is to use include with a saveContent:
This may require that you rename your template from a *.htm to be *.cfm file.
// create mailBody first using your current saveContent
savecontent variable="finalBody" {
include "#application.paths.physicalroot#\email\project1\templates\people.cfm";
}
The variable finalBody should now contain the content from the mailBody variable.
If you can have CF markup in the templates you should be able to get the results you want with this:
<cfsavecontent variable="mailBody">
<cfinclude template="#application.paths.physicalroot#\email\project1\templates\people.htm">
</cfsavecontent>

Issue with IF test on JSF xtml

sorry i tried a lot of others replies, but still i can't use it:
i want to check the value of a bean in order to print html code or not but all the time i have FALSE condition:
here the code:
<tbody>
<ui:repeat value="${wasJvmInvbean.listWasJvmInv()}" var="jvm">
<tr>
<td>${jvm.jvmStatus}</td>
<td>${jvm.cellName}</td>
<td>${jvm.serverBean.hostname}</td>
<td>${jvm.jvmName}</td>
<td>${jvm.type}</td>
<td>${jvm.profilePath}</td>
<td>${jvm.wasVersion}</td>
<c:if test="${jvm.jvmName eq 'dmgr'}">
<td>webconsole http://xxxx:8080</td>
</c:if>
<c:if test="${jvm.jvmName ne 'dmgr'}">
<td>N.A.</td>
</c:if>
<td>${jvm.fid}</td>
<td>${jvm.heapMin}</td>
<td>${jvm.heapMax}</td>
<td>${jvm.wcDefaultType}</td>
<td>${jvm.wcHost}</td>
<td>${jvm.wcPort}</td>
</tr>
</ui:repeat>
FIXED following this as example … new code is
<h:outputLink value = "https://${jvm.serverBean.hostname}:${jvm.wcPort}/ibm/console" rendered="#{jvm.type eq 'DEPLOYMENT_MANAGER'}" target="_blank" >sffsd</h:outputLink>

phpQuery: How to parse the tr's class and style clause

I have a script parsing a html page. One section parses the various tr elements. Suppose we have a tr structure like this:
<tr class="a test" style="display: none;">
<td class="numeric"></td>
<td class="date">1/1/16</td>
<td class="numeric">$2.65</td>
.... etc....
</tr>
<tr class="another tr">
...... etc......
The current code which is working fine is something like this:
$the_row_I_want = $parseSectionofCodeImlookingat->find("tr:eq($rowIwant)");
$entire_tr_in_html = $the_row_I_want->__toString();
What this does is return the html for the entire tr, from which I can parse out the class name and style sections. However I have been trying to find out how to use phpQuery syntax to parse the class name and style section out for me. Is there a way to do this using phpQuery (and how)?
OK, figured it out:
$the_row_I_want = $parseSectionofCodeImlookingat->find("tr:eq($rowIwant)");
$entire_tr_in_html = $the_row_I_want->__toString();
$the_class_attribute = $the_row_I_want->attr('class');
$the_style_attribute = $the_row_I_want->attr('style');

MVC receiving Value cannot be null or empty

I have created an ordering system which has a page that allows the end user to place/add to an order and then move to the next page to review the entire order.
I want to be able to have the user move back to the order page from the review order page and see the quantity that was just added/placed...so if I order 2 of widget A, I move to the review page and see that I have an order with 2 A widgets for a particular cost; I then move back to the order page and the quantity of 2 should still be visible to the end user and displayed with Widget A.
I have worked all of this out UNTIL I try to redisplay the Order page and its associated fields.
I get a Value cannot be null or empty error; I realize the meaning of this error and I have stepped through the code and can see that I have data!! I see nothing that is null nor empty that should not be.
What am I doing wrong?
My code:
menuIndex = 0;
intMenuTable1 = 3;
foreach (var menu_item in Model.OrderMenu)
{
if (menuIndex < intMenuTable1)
{
<tr>
<td align="center">
#Html.TextBoxFor(m => m.OrderMenu[menuIndex].Quantity, new { #class = "form-control", #style = "width:50px; height:50px;text-align:center; margin-top:50px; margin-left:10px;"})
#Html.TextBoxFor(m => m.OrderMenu[menuIndex].ID)
#Html.TextBoxFor(m => m.OrderMenu[menuIndex].ProductPrice) - **error is here**
</td>
<td align="center">
<img id="imgProduct" src=#Url.Content(#menu_item.ProductImage) />
</td>
</tr>
}
}
The error was actually BELOW the line that was coming across as an error.
I was not passing all of the model elements that I needed to recreate the view, hence the NULL values.

Grails Update a List in GSP (View) and then submit with a button

Imagine you have a table displaying a list of books (like the index does) and you want to make changes in a column called "Sold" (a checkbox for example). So once you finish "Checking" the books you have sold, you click a Button to save! How do you send back that list to the controller and update it?
So, the code is something like this, in the controller:
def aMethod(){
...
[bookInstanceList: myBookList]
}
In the GSP:
<g:each in="${bookInstanceList}" status="i" var="bookInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:link action="show" id="${bookInstance.id}">${fieldValue(bean: bookInstance, field: "author")}</g:link></td>
<td><g:checkBox name="sold" value="${bookInstance?.sold}" /></td>
<td>
</tr>
</g:each>
The idea is with the checkbox let the user change the "Sold" value from that book, and then make a submit with a Button. How can I save my new bookInstanceList?
Thank you very much
There is a simple sample app at https://github.com/jeffbrown/books which shows one way you could do this. Run the app, open the default index page, click on the link and that will take you to a page where you can click checkboxes and update the library of books.
Files of interest are https://github.com/jeffbrown/books/blob/master/grails-app/controllers/com/demo/BookController.groovy and https://github.com/jeffbrown/books/blob/master/grails-app/views/book/index.gsp.
I hope that helps.
I've removed some of the markup for brevity and to bring focus to the important bits. This is one way of doing it without relying on Javascript and what do you know, it is pure grails. Never say never, #rmlan.
<g:form action="updateSold" controller="book">
<table>
<tbody>
<g:each in="${bookInstanceList}" status="i" var="bookInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:link action="show" id="${bookInstance.id}">${fieldValue(bean: bookInstance, field: "title")}</g:link></td>
<td>
<g:checkBox name="sold" value="${bookInstance.sold}" />
<g:hiddenField name="id" value="${bookInstance.id}" />
</td>
</tr>
</g:each>
</tbody>
</table>
<g:submitButton name="updateSold" value="Update" />
</g:form>
This is the controller action:
def updateSold() {
def solds = params.list('sold')
def ids = params.list('id')
ids.eachWithIndex { id, idx ->
if (solds[idx]) {
// the book's sold has been checked, so update it to TRUE
} else {
// the books sold has not been checked, so update it to FALSE
}
}
}