Modifying column with in a table (CSS) - java

middle += "<tr class='tRow'>"
+ "<td>"
+ "<a href='" + output.get(i).get("itemURL") + "'>"
+ gallery
+ "</a>"
+ "</td>"
+ "<td class='title'>"
+ "<a href='" + output.get(i).get("itemURL") + "'>"
+ ""+ (output.get(i).get("title")).replaceAll("\"","\'\'")+"" // replaces quatations into '
+ "</a>"
+ "</td>"
+
The column having name 'title' (class name) needs to be affected by style sheet to decrease the width of column. Only that single column needs to be affected. There are more columns.
This is CSS:
td.title{
width:18%;
}
But this CSS affects all the columns in the table. The width of rest columns affected , but some of them has the width different than specified by CSS. I tried inline style sheet, but still it affects all columns.
What is the problem? Cheers
Additional details:
private String getBeginning(int tableNumber)
{
return "<html><head><title>"+ (tableNumber - 1)+"</title>"
+ "</head><body>"
+ "<table id='example' class='tablesorter' cellpadding='3' >" // border='1' cellpadding='1' cellspacing='2'
+ "<thead>"
+ "<tr class='tHead'>"
+ "<th/>"
+ "<th>Title</th>"
+ "<th>Total Price</th>"
+ "<th>Currency</th>"
+ "<th>Condition</th>"
+ "<th>Location</th>"
+ "<th>End Time</th>"
+ "<th>Map</th>"
+ "</tr>"
+ "</thead>"
+ "<tbody>";
}
middle += "<tr class='tRow'>"
+ "<td>"
+ "<a href='" + output.get(i).get("itemURL") + "'>"
+ gallery
+ "</a>"
+ "</td>"
+ "<td class='title'>"
+ "<a href='" + output.get(i).get("itemURL") + "'>"
+ ""+ (output.get(i).get("title")).replaceAll("\"","\'\'")+"" // replaces quatations into '
+ "</a>"
+ "</td>"
+ "<td>"
+ ""+output.get(i).get("total") +""
+ "</td>"
+ "<td>"
+ ""+output.get(i).get("currency")+""
+ "</td>"
+ "<td>"
+ ""+condition+""
+ "</td>"
+ "<td>"
+ ""+output.get(i).get("location")+""
+ "</td>"
+ "<td>"
+ ""+output.get(i).get("endTime").split("T")[0]+""
+ "</td>"
+ "<td>"
+ "<a href='" + getMap(location, postCode, "0") + "'>"
+ "<img src='" + getMap(location, postCode, "1") + "'> "
+"</a>"
+ "</td>"
+ "</tr>";
String end ="";
I am running this Web app on Firefox 3.6.11. Did not try to run it on different browsers.

The important thing to note here is that percentage values relate to the amount of space available to the table, not to the page or containing div. Try using an absolute value like 200. It might also complicate things if you already have width set on the table meaning you're not letting the browser decide how wide it will end up.
Without seeing the rest of your code and knowing what context the table is in, or whether you have width set on the table itself, I can tell you that setting a width on a single column when the table itself has a width set on it will change the width of the other columns as they bump about to fill up space. In this situation it is generally a good idea to let the size of the cells sort themselves out, as the algorithm used to set the width is very dynamic. Alternatively you could be very strict and set the width on each column exactly as you will want it to appear.
To read up on the subject, see the HTML specification.

Related

How to send a table row data without using any scripting in servlet?

List<Employee> records = employeeServicable.printAll();
int size = records.size();
for (int i = 0; i < size; i++) {
htmlRespone.append("<tr> " +
"<td>" + records.get(i).getId() + "</td>" +
"<td>" + records.get(i).getName() + "</td>" +
"<td>" + records.get(i).getDepartment() + "</td>"+
"<td>" + records.get(i).getPhoneNumber() + "</td>" +
"<td>" + records.get(i).getHireDate() + "</td>" +
"<td>" + records.get(i).getJob() + "</td>" +
"<td>" + records.get(i).getEducationLevel() + "</td>" +
"<td>" + records.get(i).getGender() + "</td>" +
"<td>" + records.get(i).getDateOfBirth() + "</td>" +
"<td>" + Integer.toString(records.get(i).getSalary()) + "</td>"
+ "</tr>");
}
htmlRespone.append("</table");
How can I send a specific row data to a servlet? I will attach a button at the end of each column but how will that button do it?

Can't add hover property to custom HTML mail

I'm trying to do a hover effect on an: <a href... class.
I have 2 <a href, one is a standard link and the other one has to be a button.
.btnMail:hover
#btn:hover
This works on GMAIL, but not on Outlook Web. The only way I got the :hover effect to work on outlook was doing just an a:hover but this affects all <a tags.
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false, "utf-8");
String htmlMsg = ""
+ "<style type=\"text/css\">" +
" .btnMail {\r\n" +
" background-color: #007bff;\r\n" +
" cursor: pointer;\r\n" +
" border: none;\r\n" +
" border-radius: 4px;\r\n" +
" text-decoration: none;\r\n" +
" text-decoration-color: white !important;" +
" color: white !important;\r\n" +
" padding: 15px 32px;\r\n" +
" text-align: center;\r\n" +
" display: inline-block;\r\n" +
" font-size: 18px;\r\n" +
" }\r\n" +
" .btnMail:hover{\r\n" +
" background-color: #0069d9 !important;\r\n" +
" }\r\n"
+ "</style>"
+ "<div style=\"width:100%;height:100%;\">"
+ "<div style=\"margin-left:auto;margin-right:auto;width:550px;\">"
+ "<h3>" + messages.getMessage("mail.reset", null, locale) + "</h3>"
+ "<div>" + messages.getMessage("mail.hello", null, locale) + " " + restoreUser.getUsername() + ", <br><br>"
+ messages.getMessage("mail.body", null, locale) + "</div><br>"
+ "<a id=\"btn\" class=\"btnMail\" style=\"cursor: pointer;\" href=\"" + tokenLink +"\">"
+ messages.getMessage("mail.button", null, locale) + "</a><br>"
+ "<div>" + messages.getMessage("mail.validtime", null, locale) + "<br><br>"
+ messages.getMessage("mail.thanks", null, locale) + "<br>"
+ messages.getMessage("header.companyname", null, locale) +"</div>"
+ "<br>"
+ "<hr/>"
+ "<div style=\"font-size:12px;\">" + messages.getMessage("mail.link", null, locale) +"<br>"
+ "" + tokenLink +"</div>"
+ "</div>"
+ "</div>"
+ "";
mimeMessage.setContent(htmlMsg, "text/html");
https://gyazo.com/e8f3a7105b66e6da61ed957e2437cc4d
There are many css elements that do not perform well in email clients.
Hover is one if the elements without a broad support.
This element along with support information for other ones can be found here, amongst other resources.
As for your html in your example. Keep in mind that many spam filters are looking for poor html syntax as a sign of spammy content. You should consider adding html, head and body tags to your message.

sending Meeting request outlook in java , and linebreaks in "DESCRIPTION:" are takenout

String textEmail= "Hi, \n this is an automatic message \n from sender.
StringBuffer buffer = sb.append("BEGIN:VCALENDAR\n" +
"PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN\n" +
"VERSION:2.0\n" +
"METHOD:REQUEST\n" +
"BEGIN:VEVENT\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:" +emailAdressTo+"\n" +
"ORGANIZER:MAILTO:XX#gmail.com\n" +
"DTSTART:" + meetingStartTime + "\n"+
"DTEND:" + meetingEndTime + "\n"+
"LOCATION: Room FR PAR-New York\n" +
"TRANSP:OPAQUE\n" +
"SEQUENCE:0\n" +
"UID:"+ uniqueId +"\n" +
"DTSTAMP:"+ meetingEndTime + "\n" +
"CATEGORIES:Meeting\n" +
"DESCRIPTION:"+textEmail +"\n" +
"SUMMARY:"+subjectEmail+"\n" +
"PRIORITY:5\n" +
"CLASS:PUBLIC\n" +
"BEGIN:VALARM\n" +
"TRIGGER:PT1440M\n" +
"ACTION:DISPLAY\n" +
"DESCRIPTION:Reminder\n" +
"END:VALARM\n" +
"END:VEVENT\n" +
"END:VCALENDAR");
email.setContent(buffer.toString(),"text/calendar");
email.setCharset("UTF-8");
the linebreaks breaks are not taken in consideration and my output is just:
"Hi,this is an automatic message from sender"
I have tried every think in this post:
[1]How do I format a String in an email so Outlook will print the line breaks? but still same result Any help would be apreciated, thks
List item

Collapsing Rows using bootstrap - dynamically large table - only first row collapsing

I am creating a table that I want to have collapsing detail on each row. I am able to get this working for the first row of the table, but for every row after this, the button does not toggle. My code is below. I know I am probably missing something very simple here, but I am fairly new to web development. Any help is appreciated.
.js
for (var z=0;z<documentData.length;z++) {
$("#documents-result-table > tbody").append(
"<tr>" +
"<td>" + documentData[z].documentIdocNumber + "</td>" +
"<td>" + documentData[z].docNumber + "</td>" +
"<td>" + documentData[z].documentType + "</td>" +
"<td>" + documentData[z].status + "</td>" +
"<td>" + documentData[z].createdDate + "</td>" +
"<td>" + documentData[z].modifiedDate + "</td>" +
"<td>" + documentData[z].customerId + "</td>" +
"<td>" + documentData[z].customerName + "</td>" +
"<td><a target=\"_blank\" href=\"" + contextPath + "/viewPdf.do?documentIdocNumber=" + documentData[z].documentIdocNumber + "\" class=\"glyphicon glyphicon-eye-open\"></a></td>" +
"<td><a target=\"_blank\" href=\"" + contextPath + "/saveBak.do?documentIdocNumber=" + documentData[z].documentIdocNumber + "\" class=\"glyphicon glyphicon-floppy-save\"></a></td></tr>"
+ "<tr class=\"collapse\" id=\"collapseme\">" +
"<td></td><td colspan=\"9\"><table class=\"table table-striped table-curved\"><tr><th>Customer Id</th><th>Customer Name</th><th>Billing Plant</th><th>Country Code</th><th>Routing Code</th><th>Language</th></tr>" +
"<tr>" +
"<td>" + documentData[z].customerId + "</td>" +
"<td>" + documentData[z].customerName + "</td>" +
"<td>" + documentData[z].billingPlant + "</td>" +
"<td>" + documentData[z].countryCode + "</td>" +
"<td>" + documentData[z].routingCode + "</td>" +
"<td>" + documentData[z].language + "</td></tr>" +
"</table></td></tr>");
$('.collapse').collapse({toggle: false});
$('button span').click(function() {
$("#collapseme").collapse("toggle");
var span = $('button span').hasClass('glyphicon-chevron-down');
if(span){
$(".glyphicon-chevron-down").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-right");
}
else{
$(".glyphicon-chevron-right").removeClass("glyphicon-chevron-right").addClass("glyphicon-chevron-down");
}
});
My table is declared in another .jsp file, but I do not think this code is needed for a solution. Also to mention, this loop is inside an AJAX call in my .js file.
Thanks!

Capturing FORM values to update in POST

I have an HTML form in a servlet with several input parms, when I press the Submit button, I want to take the values from the form and write those to a file. I am not certain how to capture the parms to be used in the next .jsp. Here is my code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.text.*;
import java.util.Random;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class CreateCust extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
// Generate a Customer Account using the Random Number Generator
// Calculate Confirmation Number
Random randomGenerator = new Random();
int custNum = randomGenerator.nextInt(10000);
String custId = "CST" + custNum;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Customer Profile Information";
String MainPageURL =
response.encodeURL("/csj/CustomerAccounts.html");
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=\"CENTER\">" + title + "</H1>");
out.println("<BR>" +
"<BR>" +
"Previous Page");
out.println
("<Form>\n" +
"<CENTER>" +
"Please Enter the following Information:\n" +
"<TABLE border=1>" +
"<TR>" +
"<TD>" +
"Customer ID: " +
"</TD>" +
"<TD>" +
"<Label>" + custId + " </Label>\n" +
"</TD>" +
"</TR>" +
"<TR>" +
"<TD>" +
"Name:" +
"</TD>" +
"<TD>" +
"<Input type=\"Text\" name=\"F_name\" </input>\n" +
"</TR>" +
"<BR>" +
"<TR>" +
"<TD>" +
"Street Address:" +
"</TD>" +
"<TD>" +
"<Input type=\"Text\" name=\"F_Add1\" </input>\n" +
"</TD>" +
"</TR>" +
"<BR>" +
"<TR>" +
"<TD>" +
"Apt or Suite:" +
"</TD>" +
"<TD>" +
"<Input type=\"Text\" name=\"F_Add2\" </input>\n" +
"</TD>" +
"</TR>" +
"<BR>" +
"<TR>" +
"<TD>" +
"City:" +
"</TD>" +
"<TD>" +
"<Input type=\"Text\" name=\"F_City\" </input>\n" +
"</TD>" +
"</TR>" +
"<BR>" +
"<TR><TD>" +
"State:" +
"</TD><TD>" +
"<Input type=\"Text\" name=\"F_state\" </input>\n" +
"</TD>" +
"</TR>" +
"<BR>" +
"<TR><TD>" +
"Zip Code:" +
"</TD>" +
"<TD>" +
"<Input type=\"Text\" name=\"F_Zip\" </input>\n" +
"</TD>" +
"</TR>" +
"<BR>" +
"<TR>" +
"<TD>" +
"Phone Number:" +
"</TD>" +
"<TD>" +
"<Input type=\"Text\" name=\"F_Phone\" </input>\n" +
"</TD>" +
"</TR>" +
"<BR>" +
"<TR><TD>" +
"Cable Plan:" +
"</TD>" +
"<TD>" +
"<select>\n" +
"<option value=\"selcab\">Select Cable</option>\n" +
"<option value=\"Basic50\">Basic50</option>\n" +
"<option value=\"Basic100\">Basic100</option>\n" +
"<option value=\"Ultimate200\">Ultimate200</option>\n" +
"</select>\n" +
"</TD>" +
"</TR>" +
"<BR>" +
"<TR><TD>" +
"Internet Plan:" +
"</TD>" +
"<TD>" +
"<select>\n" +
"<option value=\"selInt\">Select Internet</option>\n" +
"<option value=\"speedlane\">SpeedLane</option>\n" +
"<option value=\"lightlane\">LightLane</option>\n" +
"</select>\n" +
"</TD>" +
"</TR>" +
"<TABLE>" +
"</CENTER>" +
"</Form>" );
String confirmURL =
response.encodeURL("/csj/ConfirmCust");
// "Proceed to Checkout" button below table
out.println
("</TABLE>\n" +
"<FORM ACTION=\"" + confirmURL + "\">\n" +
"<BIG><CENTER>\n" +
"<INPUT TYPE=\"SUBMIT\"\n" +
" VALUE=\"Create Account\">\n" +
"</CENTER></BIG>" +
"</FORM>");
out.println("</BODY></HTML>");
}
}
when I press the Submit button, I want to take the values from the form
For this you have to do request.getParameter("input parameter name");
Well in your servlet you have 2 forms one having action and another does not have.
See this
out.println
("</TABLE>\n" +
"<FORM ACTION=\"" + confirmURL + "\">\n" +
"<BIG><CENTER>\n" +
"<INPUT TYPE=\"SUBMIT\"\n" +
" VALUE=\"Create Account\">\n" +
"</CENTER></BIG>" +
"</FORM>");
here form action is present but when you press submit it calls confirmURL but mo values are passed(as it is not having any input parameter).
Now in this
out.println
("<Form>\n" +
"<CENTER>" +
"Please Enter the following Information:\n" +
"<TABLE border=1>" +
"<TR>" +
"<TD>" +
"Customer ID: " +
"</TD>" +
"<TD>" +
"<Label>" + custId + " </Label>\n" +
....................
input parameter are present but no submit button and no form action
So no action will be performed and hence no values will be passed.

Categories

Resources