Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_dzienna_15_09
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_dzienna_15_09
Commits
1fbb97f6
Commit
1fbb97f6
authored
Oct 07, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Poprawki w generowaniu PDF
parent
7632e2c1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
3 deletions
+10
-3
RProducts.java
PC34-RestSerwer/src/main/java/sklep/rest/RProducts.java
+2
-2
PDFWriter.java
PC34-RestSerwer/src/main/java/sklep/rest/ext/PDFWriter.java
+7
-0
sklep-fo.xsl
PC34-RestSerwer/src/main/webapp/WEB-INF/sklep-fo.xsl
+1
-1
No files found.
PC34-RestSerwer/src/main/java/sklep/rest/RProducts.java
View file @
1fbb97f6
...
...
@@ -38,7 +38,7 @@ public class RProducts {
// ale implementacja REST Easy (WildFly/JBoss) zastosuje pierwszy z formatów podanych w adnmotacji.
// Glassfish i WebLogic tak nie robią - wybierają "losowo".
@GET
@Produces
({
"application/json"
,
"application/xml"
,
"text/plain"
})
@Produces
({
"application/json"
,
"application/xml"
,
"text/plain"
,
"application/pdf"
})
public
List
<
Product
>
readAll
()
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
...
...
@@ -63,7 +63,7 @@ public class RProducts {
}
@GET
@Produces
({
"application/json"
,
"application/xml"
,
"text/plain"
})
@Produces
({
"application/json"
,
"application/xml"
,
"text/plain"
,
"application/pdf"
})
@Path
(
"/{id}"
)
public
Product
readOne
(
@PathParam
(
"id"
)
int
productId
)
throws
DBException
,
RecordNotFound
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
...
...
PC34-RestSerwer/src/main/java/sklep/rest/ext/PDFWriter.java
View file @
1fbb97f6
...
...
@@ -32,6 +32,13 @@ public class PDFWriter implements MessageBodyWriter<Object> {
public
void
writeTo
(
Object
obj
,
Class
<?>
type
,
Type
genericType
,
Annotation
[]
annotations
,
MediaType
mediaType
,
MultivaluedMap
<
String
,
Object
>
httpHeaders
,
OutputStream
output
)
throws
IOException
,
WebApplicationException
{
String
fileName
=
"products.pdf"
;
if
(
obj
instanceof
Product
)
{
Product
product
=
(
Product
)
obj
;
fileName
=
product
.
getProductName
().
replace
(
' '
,
'_'
)
+
".pdf"
;
}
// httpHeaders.add("Content-Disposition", "attachment;filename=" + fileName);
httpHeaders
.
add
(
"Content-Disposition"
,
"inline;filename="
+
fileName
);
ObslugaXSL
obslugaXSL
=
new
ObslugaXSL
(
servletContext
);
obslugaXSL
.
wypiszPDF
(
obj
,
output
);
}
...
...
PC34-RestSerwer/src/main/webapp/WEB-INF/sklep-fo.xsl
View file @
1fbb97f6
...
...
@@ -37,7 +37,7 @@
border-color=
"#2233AA"
>
<fo:block
font-weight=
"bold"
font-size=
"14pt"
margin-bottom=
"1em"
color=
"#FF2244"
>
<xsl:apply-templates
select=
"
product-
name"
/>
<xsl:apply-templates
select=
"name"
/>
</fo:block>
<fo:block
font-weight=
"bold"
color=
"green"
>
<xsl:text>
Cena:
</xsl:text>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment