Help coderanch get a
new server
by contributing to the fundraiser

Mattias Fransson

Greenhorn
+ Follow
since May 14, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mattias Fransson

Hi, my problem is that when I marshal an java-object to xml using the castor tool all line-breaks are being removed from the strings in the object that i parse to xml.
For example if I have an movieObject with a string that contains a description of the movie, that string could look like this:
"Taxi driver:

Taxi driver is a rather good movie...

The bad parts with the movie is that..."


when i parse this to xml using castor it looks like this in the xml file:
"Taxi driver: Taxi driver is a rather good movie... The bad parts with the movie is that..." - it has removed the line breaks and replaced them with one or two whitespaces.

Would be happy if there are anyone that knows how to keep the line breaks in the xml document and could tell me how?

/Mattias
Hi, I have following code in my jsp site and I wonder how I can get the text in the TextArea using javabean?
<FORM ACTION="???">
<table>
<font face="times roman" color="#666699" size="+2"> Send a reply</font>
<br>
<br>
<TEXTAREA name="feedback" COLS=35 ROWS=10>
</TEXTAREA></td></tr></table>
<INPUT type="submit" value="Skicka">
<INPUT type="reset" value="Radera">
</FORM>
/Mattias
Hi I have an jsp site where people can log in, and I just wonder how I can check that the email-adress is valid with javascript?

Originally posted by Gizzmo Zeuzere:
Thanks but it doesn't work. In fact, it prints only the first page and I don't see how to print the others.


What you have to do is calculate the number of pages and check if all the pages have been printed by putting the following if loop in your print method.
if ( pageIndex >= totalNumPages ) {
return Printable.NO_SUCH_PAGE;
}
To calculate the totalNumPages you have to first calculate the page height and the height of the component(e.g panel) you are trying to print.
double pageHeight = pageFormat.getImageableHeight();
double componentHeight = component.getSize().height;
int totalNumPages = (int) Math.ceil(componentHeight/pageHeight);

------------------
23 years ago
Hi, I've looked on the different tutorial and I can't find any thing that I understand so I would be happy for any answer I get.
This is my code, the problem is that it not printout on multiple pages so all lines does not being printed.
public void pprint()
{
PrinterJob printerJob = PrinterJob.getPrinterJob();
PageFormat formating = new PageFormat();
formating = printerJob.pageDialog(formating);
book = new Book();
book.append(this, formating);
printerJob.setPageable(book);
boolean doPrint = printerJob.printDialog();
if (doPrint)
{
try
{
printerJob.print();
}
catch (PrinterException exception)
{
System.err.println("Printing error: " + exception);
}
}
}
public int print(Graphics g, PageFormat format, int pageIndex)
{
Graphics2D g2d = (Graphics2D) g;
g2d.translate(format.getImageableX(), format.getImageableY());
g2d.setPaint(Color.black);
int y = 15;
for(int j = 0; j < sumOfRows; j++)
{
if(!text[j].getText().equals(""))
{
int lineLength = text[j].getText().length();
if (lineLength > 55)
{
String temp1 = text[j].getText().substring(0, 55);
String temp2 = text[j].getText().substring(56, lineLength);
g2d.drawString(temp1, 15, y);
y += 15;
g2d.drawString(temp2, 15, y);
}
else
g2d.drawString(text[j].getText(), 15, y);
}
y += 15;
}
return Printable.PAGE_EXISTS;
}

Would be happy for answer
Mattias Fransson
23 years ago