creating the welcome page - jsp-tags

why is the user name not desplayed on the web page using the following code?
String custId = (String) session.getAttribute("customerId");
String emailId = (String) session.getAttribute("emailId");
String phoneNumber = (String) session.getAttribute("phoneNumber");
<body>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table width="70%" align="center" border="1">
<tr>
<td align="center">Welcome to Going Green !</td>
</tr

Are you sure that your sessions contain anything ?
where do you place the string variables in the html code ?

Related

Update form from another form using <f: ajax> in JSF

Good day,
I am developing an application in java server faces 2.2.20 and mariadb 10.4 databases.
I have a problem when updating with f: ajax to another form where I have a table that lists the products with their respective images entered, but the images returned by the method from the bean to the img in html are not displayed, although the image if it has in the src its respective route; The good content as text if it is updated correctly without reloading the page this means that if ajax works in part.
This is the code where the product data is entered and the image is uploaded to the controller.
<h:form id="crearCatalogos" enctype="multipart/form-data"> <!--prependId="false" -->
<div class="container">
<div class="row">
<div class="col-lg-5">
<fieldset>
<legend> Informacion:</legend>
<h:messages style="color:red"></h:messages>
<label>Nombre de categoria: </label><br/>
<h:inputText value="#{FileUploadFormBeanRequest.nombreCatalogo}" id="primerNombre" class="inputPersonalizado" html5:placeholder="Ingrese el nombre" maxlength="20" required="true" validatorMessage="No debe superar 20 caracteres" requiredMessage="Ingrese el nombre"></h:inputText><br/><br/>
<label>Seleccionar imagen: </label><br/>
<h:inputFile id="imgInp" value="#{FileUploadFormBeanRequest.archivoCarga}" validator="#{FileUploadFormBeanRequest.validarImagenCategoria}" class="inputPersonalizadoFile"> </h:inputFile>
<br/><br/>
<h:commandButton class="btn btn-primary" value="Cargar">
<f:ajax render="#form : formVerCatalogos : table_verCatalogos" event="action" execute="#form" listener="#{FileUploadFormBeanRequest.guardarDatosCategoria()}"></f:ajax>
</h:commandButton>
</fieldset>
<br/><br/>
</div>
<div class="col-lg-5 imgCategorias">
<div class="text-center">
<img id="noImagen54" src="../TEMPLATE/img/noImagen.jpeg" class="rounded img-thumbnail" alt="..."/>
<img id="imagenCategoriaFile" src="#" class="rounded img-thumbnail imagenCategoriaFile" alt="..."/>
</div>
</div>
</div>
</div> ​
</h:form>
first form view
second view with data
This is the code of the controller method that is called from the commandButton of the view, which is responsible for saving the data entered of the product and the respective image.
public void guardarDatosCategoria() {
this.archivoCarga = archivoCarga;
try (InputStream input = archivoCarga.getInputStream()) {
String fileName = archivoCarga.getSubmittedFileName();
Calendar hoy = Calendar.getInstance();
DateFormat formatter = new SimpleDateFormat("yyyyMMdd-hhmmss");
String[] ext = fileName.split("\\.");
fileName = ext[0] + formatter.format(hoy.getTime()) + "." + ext[1];
File directorio = new File(folder+"/"+this.nombreCatalogo);
if(!directorio.exists()){
if(directorio.mkdir()){
directorio.mkdir();
Files.copy(input, new File(directorio, fileName).toPath());
//System.out.println(directorio.getAbsolutePath());
}else{
System.out.println("Error al crear directorio");
}
}
//String salida = FacesContext.getCurrentInstance().getExternalContext().getApplicationContextPath();
//System.out.println(salida);
Catalogo objCatalogo = new Catalogo();
objCatalogo.setNombre(this.nombreCatalogo);
catalogoFacadeLocal.create(objCatalogo);
Imagen objImagen = new Imagen();
objImagen.setRuta("../Resources/img/Categorias/"+this.nombreCatalogo+"/"+fileName);
objImagen.setEstado("Principal");
objImagen.setIdCatalogo(objCatalogo);
imagenFacadeLocal.create(objImagen);
} catch (Exception e) {
e.printStackTrace();
}
this.archivoCarga=null;
this.nombreCatalogo="";
}
This is the view code that I need to reload using f: ajax de jsf
<!--VER CATEGORIAS -->
<div class="tab-pane fade active show" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
<h:form id="formVerCatalogos">
<table id="table_verCatalogos" class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">CATEGORIA</th>
<th scope="col">TIPO</th>
<th scope="col">IMAGEN</th>
</tr>
</thead>
<tbody>
<c:forEach items="#{FileUploadFormBeanRequest.listarImagenes()}" var="catalogoImg" varStatus="paso" rendered="#{!empty FileUploadFormBeanRequest.listarImagenes()}" >
<tr>
<th scope="row">#{paso.index+1}</th>
<td>#{catalogoImg.idCatalogo.nombre}</td>
<td>#{catalogoImg.estado}</td>
<td><h:graphicImage id="noImagen" value="#{catalogoImg.ruta}" class="rounded img-thumbnail img_ver_categorias"></h:graphicImage> </td>
</tr>
</c:forEach>
</tbody>
</table>
</h:form>
</div>
[enter image description here][3]
This is the code of the controller that is responsible for returning the data entered, to be displayed in the table that I need to reload.
public List<Imagen> listarImagenes(){
try {
return imagenFacadeLocal.findAll();
} catch (Exception e) {
return null;
}
}
This is how you look when the data entered is saved and the jsf ajax is executed, but the image cannot be visualized even if I look at the src of the img tag, the path is found. The only way to view the page is to reload the entire page arbitrarily, but it is not the idea.
in this view the text rendering is done, but the image is not displayed
Inspecting the element with f12, we can see that the img tag, if it has the correct path, but is not displayed with the JSF f: ajax.
I am very grateful that you give me a help, I have already searched, read, documented and the truth is that I cannot solve it on my own, I do not understand what it takes. Happy day thank you very much.
INSPECTING THE VIEW WITH F12, it is shown that the src attribute has the image path

Classic asp export to excel (with parameter)

I am using the education iSAMS software to produce a report, then export that data to Excel. Almost everything is written in Classic ASP, and it's a 2-frame window, containing Student IDs on the left frame, and a report for each student ID on the right frame. Click on a student of the left, and the report shows in the right pane.
The report uses the Student ID as a parameter :
paramBuilder.NextParameter(intID)
... and this works fine and produces the report from the SQL loop.
However, I'm unable to use the parameter in the Excel export part (I get the error "syntax error or access violation"). If I remove the parameter from the WHERE clause, the export works (although it exports all Student IDs, not just the one).
I've tried just about everything I can think of, but I still hit a brick wall. Is it possible to re-use this parameter in the export?
Thanks in advance.
Here is the code :
<!--#include file="../../system/includes/inc_security.asp"-->
<!--#include file="../../system/includes/inc_theme.asp"-->
<% 'viewstudent-test.asp-v111-11-09-2017 --Includes Export to Excel
'txtModule="iSAMS_SCHOOLDIRECTORY"
'txtContext="SDSTUDENT"
intID = request.querystring("id")
%>
<!--- SHOW THE SUBJECT REPORTS --->
<table border="1px" width="100%">
<tr>
<td>Subject</td>
<td>Subject Report</td>
</tr>
<%
sql = "SELECT DISTINCT txtSchoolID, txtID, txtCommentID, txtComment FROM CAN_Tbl_UCAS_Reports WHERE intReportType = 1 AND txtSchoolID = " & paramBuilder.NextParameter(intID) & " ORDER BY txtID"
Set rsRecord = Database.GetRs(sql, conn, paramBuilder.Parameters)
if not rsRecord.EOF then
do until rsRecord.EOF
' First we need to create our Variables
SchoolID = rsRecord("txtSchoolID")
ConID = rsRecord("txtCommentID")
Com = rsRecord("txtComment")
%>
<tr>
<td style="text-align:center; vertical-align:top; height:10px"><%Response.Write(rsRecord.Fields("txtID").value)%></td>
<td style="text-align:center">
<form action="updateform.asp" method="post">
<input type="hidden" name="ID" value="<%=ConID%>" />
<input type="hidden" name="SchoolID" value="<%=SchoolID%>" />
<textarea rows="3" cols="180" name="comment"><%=Com%></textarea>
</form>
<td>
</tr>
<%
rsRecord.Movenext
loop
end if
rsRecord.close
set rsRecord = nothing
%>
</table>
<%If Request("ACT")="xls" Then
'Build & Execute Your SQL Command
SQL = "SELECT DISTINCT txtSchoolID, txtID, SubjectTeacher, txtComment FROM CAN_Tbl_UCAS_Reports WHERE intReportType = 1 AND txtSchoolID = '" & intID & "' ORDER BY txtID"
Set rstSearch = conn.Execute(SQL)
'Set the HTTP Header
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "filename=""Excel Export.xls"""
'Output Table %>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<th>Header 1</th><th>Header 2</th><th>Header 3</th>
</tr><% Do While Not rstSearch.EOF %>
<tr>
<td><%=rstSearch(1)%></td><td><%=rstSearch(3)%></td>
</tr>
<% rstSearch.MoveNext : Loop %>
</table>
<%
'Stop Processing Page Now
Response.End
End If
%>
<form action="?" method="post">
<input type="hidden" name="ACT" value="xls">
<input type="submit" value="Export To Excel">
</form>
</body>
</html>
<!--#include file="../../system/connections/inc_dbconnclose.asp"-->

Thymeleaf for each string replace a substring

I have a list of objects. Every Object has a name with a specific prefix. Now I want to replace this prefix with an empty String.
My Code:
Controller:
#Secured("ROLE_ADMIN")
#RequestMapping(value = "/admin/userManagement", method = RequestMethod.GET)
public String showUserManagement(Model model) {
model.addAttribute("userList", userDelegate.getAllUserForClient(getCompanyAuthority().getName()));
model.addAttribute("companyName", getCompanyAuthority().getName());
return "admin/user_management";
}
My html snippet:
<table class="table table-striped table-hover">
<thead>
<tr>
<th>ID</th>
<th>E-mail</th>
<th th:text="#{adminArea.userManagementReport}">Reports</th>
<th th:text="#{adminArea.userManagementRole}"></th>
<th>Edit</th>
</tr>
</thead>
<tbody>
<tr th:each="user,itrStat : ${userList}">
<td th:text="${itrStat.index}"></td>
<td th:text="${user.username}"></td>
<td>
<small th:each="report : ${user.reports}"
th:utext="${#strings.replace(report.name,companyName + '_','')} : ${companyName}"></small>
<br th:each="report : ${user.reports}"></br></td>
</tr>
</tbody>
</table>
the Important part is:
<small th:each="report : ${user.rep orts}"
th:utext="${#strings.replace(report.name,companyName + '_','')} : ${companyName}"></small>
For every report name, I want to remove the companyName prefix. So TEST_filename.txt -> filename.txt
Can someone help me?
Use substringAfter:
<small th:each="report : ${user.reports}"
th:utext="${#strings.substringAfter(report.name,'_'}></small>
Of course, you'll want to make sure that your company names don't also contain the underscore delimiter before doing this.
don’t do that ,try this instead ,
to split the String based on "_" and take the second word by mentioning the index .

trying to click a button within one of several tabs within an ie webpage using vba

I am having trouble figuring out how to use vba to automate clicking a button that is located with one of a set of tabs in a web page.
I used inspect element in firefox to figure out the element id for the button i want to click (which is "runscreen" but i cannot find this element id when viewing the actual web page's source code, also the button shares this element id with another button on another tab. Both buttons have the same “run” as their innertext and "runscreen" as their element id's but have different element hid’s. I can’t figure out why the element id is viewable by inspecting the button but is not viewable by selecting to view the webpage’s source code either with ie or firefox. my excel version is 2010 and i'm using ie9. The only part of the webpage’s code that seems to me hidden is the part that deals with the elements within the tabs. I think it may have something to do with
img src="/images/new/ajax-loader-trans.gif"
I first tried this code:
'IE.document.getElementById("runscreen").click
the vba returned an error of "object required", i am guessing because the element id is not directly on the web page source code but hidden somehow
then i tried
Call IE.document.parentWindow.execScript("runscreen()", "JavaScript")
I think the page is somehow using a function when the button is clicked but I can't figure out if this is the case or not.
I have been searching all over for a solution to clicking the button but have been unable to figure it out. any help would be greatly appreciated.
Here is the code I find when I use firefox to inspect the element I'm trying to click (but this code is not visible when I select view source in ie/firefox):
<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span>
Run
</span>
And here is more of the surrounding code (only the first line of this code is viewable when viewing the web page source code)
<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom">
<div id="freeform-cont">
<div class="vocab-ref"> … </div>
</div>
<div id="screen-criteria-section">
<div id="commonCont">
<div id="commonButtons" style="padding-bottom:4px; float:left; "> … </div>
<div style="text-align:right">
<span class="parameterTitle"> … </span>
<span class="parameterValue"> … </span>
<span style="padding-left: 10px">
<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span> … </span>
</a>
</span>
<span style="padding-left: 5px"> … </span>
<span id="universeTotal" class="universe-subtotal"> … </span>
</div>
<div id="commonRules" style="clear:both; zoom: 1"> … </div>
</div>
and here is the code for the tabs that is viewable when I select view source in ie/firefox, the button i'm trying to click is in the "rules" tab which has the element id "scrtab_1". The last part of this code matches partially with the first part of the above code :
<div id="screentabs" style="zoom: 1;">
<div class="tabs-nav">
<table cellpadding="0" cellspacing="0" border="0"><tr>
<td class="toggle-width"><img id="toggleScrWidth" src="/images/new/width-wide.gif" width="16" height="16" border="0" title="Toggle Display Width" alt=""/></td>
<td ><a id="scrtab_0" class="scr-tab-link help-enabled" hid="screen-about-user" href="javascript: void(0);" onfocus="blur()">About</a></td>
<td ><a id="scrtab_5" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Notes</a></td>
<td ><a id="scrtab_7" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Main Settings</a></td>
<td class="on"><a id="scrtab_1" class="scr-tab-link help-enabled" hid="screen-rules" href="javascript: void(0);" onfocus="blur()">Rules</a></td>
<td ><a id="scrtab_6" class="scr-tab-link help-enabled" hid="screen-hedge" href="javascript: void(0);" onfocus="blur()">Hedge Rules</a></td>
<td ><a id="scrtab_2" class="scr-tab-link help-enabled" hid="screen-results" href="javascript: void(0);" onfocus="blur()">Results</a></td>
<td ><a id="scrtab_3" class="scr-tab-link help-enabled" hid="screen-backtest" href="javascript: void(0);" onfocus="blur()">Backtest</a></td>
<td ><a id="scrtab_4" class="scr-tab-link help-enabled" hid="screen-advancedbacktest" href="javascript: void(0);" onfocus="blur()">Advanced Backtest</a></td>
</tr></table>
</div>
<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom"><div align="center"><img src="/images/new/ajax-loader-trans.gif" alt="loading"></div></div>
</div>
</div>
</div>
You need to loop through the each element which has id runScreen then find the right one using classname which is inside anchor element , Something like below (Untested)
Dim elementcollection as htmlelementcollection
Set htmlelementcollection=Ie.Document.GetElementById("runScreen").GetElementsByTagName("a")
Dim element as htmlelement
For Each element In elementcollection
Dim Str As String = element.GetAttribute("className")
If element.GetAttribute("className") = "general-button general-button-green help-enabled" Then
element.InvokeMember("Click")
Do Until Ie.readyState = 4
DoEvents
Loop
Exit For
End If
Next

People search in SharePoint using partial names

My employer is switching their internal portal over to SharePoint. One of the highly used features of the previous portal was a 'people search' that allowed partial names. SharePoint 2007 defaults to keyword searches which only match against the exact word(s) given as search terms. It can do full-text searches but you have to provide the property name, e.g. "FirstName:tom" (without the quotes of course). That works for a programmatic solution but not for end users.
Is there a way in SharePoint 2007 to let users search for people using partial names?
I found this solution that works well enough for us.
Add a ContentEditor web part to the target page and go to the HTML editor button. Add the following HTML code. It creates two input fields (firstname/lastname) and then creates a query with the search terms included as property searches which will invoke the full-text search.
Note: you need to replace the search result page with the appropriate location for your configuration.
<script language="javascript">
//function to handle enter on keyboard
function txtWildPeopleFinder_KeyDown(e)
{
if (e.keyCode == 13 || e.keyCode==10)
{
e.returnValue=false;
DoWildPeopleSearch();
return false;
}
else
return true;
}
//escape apostrophes in search strings
function escapestr(str)
{
return str.replace("'","%22");
}
//search function
function DoWildPeopleSearch()
{
var firstname = escapestr(document.all["firstname"].value);
var lastname = escapestr(document.all["lastname"].value);
var url;
//search on last name
if(firstname == "")
{
url = "/searchcenter/Pages/peopleresults.aspx?k=LastName%3A" + lastname;
window.location=url;
return;
}
//search on first name
if(lastname == "")
{
url = "/searchcenter/Pages/peopleresults.aspx?k=FirstName%3A" + firstname;
window.location=url;
return;
}
//first and last
url = "/searchcenter/Pages/peopleresults.aspx?k=lastname%3A" + lastname + "%20FirstName%3A" + firstname;
window.location=url;
return;
}
</script>
<table cellpadding="2" cellspacing="0" border="0" width="100%" ID="Table3">
<tr>
<td width="80" nowrap>
First Name:
</td>
<td width="100%">
<input size="20" maxlength="100" id="firstname" name="firstname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
</td>
</tr>
<tr>
<td width="80" nowrap>
Last Name:
</td>
<td>
<input size="20" maxlength="100" id="lastname" name="lastname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="button" onclick="DoWildPeopleSearch()" value="Search">
</td>
</tr>
</table>

Resources