Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit abbcf698
authored
Oct 24, 2012
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
print user stuff @ send picture page using new code
1 parent
4f849d26
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
3 deletions
code/LanBortalWeb/WebContent/WEB-INF/faces-config.xml
code/LanBortalWeb/WebContent/resources/cditools/salespoint/list.xhtml
code/LanBortalWeb/WebContent/useradmin/sendPicture.xhtml
code/LanBortalWeb/WebContent/useradmin/userCartShow.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserView.java
code/LanBortalWeb/WebContent/WEB-INF/faces-config.xml
View file @
abbcf69
...
...
@@ -132,6 +132,15 @@
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>
useradmin/sendPicture
</display-name>
<from-view-id>
/useradmin/sendPicture.xhtml
</from-view-id>
<navigation-case>
<from-outcome>
accepted
</from-outcome>
<to-view-id>
/useradmin/edit.xhtml
</to-view-id>
<redirect
/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>
voting/create
</display-name>
<from-view-id>
/voting/create.xhtml
</from-view-id>
<navigation-case>
...
...
code/LanBortalWeb/WebContent/resources/cditools/salespoint/list.xhtml
View file @
abbcf69
...
...
@@ -17,7 +17,7 @@
<h:outputText
rendered=
"#{salespointListView.salespoints.rowCount le 0}"
value=
"#{i18n['salespoint.noSalesPoints']}"
/>
<h:form
rendered=
"#{salespointListView.salespoints.rowCount gt 0}"
>
<h:dataTable
styleClass=
"bordertable"
id=
"salespointList"
value=
"#{salespointListView.salespoints}"
var=
"salespoint"
>
...
...
code/LanBortalWeb/WebContent/useradmin/sendPicture.xhtml
View file @
abbcf69
...
...
@@ -10,6 +10,7 @@
<f:metadata>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userView.initView}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userView.prepareCardDownload}"
/>
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['sendPicture.header']}
</h1>
...
...
@@ -62,6 +63,12 @@
<ui:fragment
rendered=
"#{userView.canManage()}"
>
<h2>
Ylläpito
</h2>
<h:form>
<p:commandButton
action=
"#{userView.prepareCardDownload()}"
rendered=
"#{userView.waitForAcceptance==false}"
value=
"print card"
ajax=
"true"
update=
"@form"
onclick=
"PrimeFaces.monitorDownload(start, stop)"
>
<p:fileDownload
value=
"#{userView.streamedFile}"
/>
</p:commandButton>
<p:commandButton
action=
"#{userView.acceptPrintedCard()}"
value=
"accept printed card"
/>
</h:form>
<!-- <h:form>
<h:commandButton action="#{userView.makeCard()}" value="#{i18n['user.makeCard']}" />
<h:dataTable var="card" value="#{userCardView.printedCards}">
<h:column>
...
...
@@ -77,7 +84,7 @@
</h:column>
</h:dataTable>
</h:form>
</h:form>
-->
<h3>
RFID
</h3>
<h:form
rendered=
"#{empty readerNameContainer.readerId}"
>
...
...
code/LanBortalWeb/WebContent/useradmin/userCartShow.xhtml
View file @
abbcf69
...
...
@@ -20,7 +20,7 @@
<h:commandButton
action=
"#{userCartView.removeCurrent()}"
value=
"#{i18n['usercart.removeCurrent']}"
/>
<h:commandButton
action=
"#{userCartView.next()}"
value=
"#{i18n['usercart.next']}"
rendered=
"#{userCartView.userCartSize > (userCartView.current+1)}"
/></h:form>
<h:link
outcome=
"/card/massprint"
value=
"
yarr
"
>
<h:link
outcome=
"/card/massprint"
value=
"
Mass Print
"
>
<f:param
name=
"cid"
value=
"#{javax.enterprise.context.conversation.id}"
/>
</h:link>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserView.java
View file @
abbcf69
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
user
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.List
;
...
...
@@ -7,11 +10,15 @@ import javax.ejb.EJB;
import
javax.enterprise.context.Conversation
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.inject.Produces
;
import
javax.faces.application.FacesMessage
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
org.primefaces.event.CaptureEvent
;
import
org.primefaces.model.CroppedImage
;
import
org.primefaces.model.DefaultStreamedContent
;
import
org.primefaces.model.StreamedContent
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -28,6 +35,7 @@ import fi.insomnia.bortal.model.PrintedCard;
import
fi.insomnia.bortal.model.Role
;
import
fi.insomnia.bortal.model.User
;
import
fi.insomnia.bortal.model.UserImage
;
import
fi.insomnia.bortal.util.MassPrintResult
;
import
fi.insomnia.bortal.web.annotations.LoggedIn
;
import
fi.insomnia.bortal.web.annotations.SelectedUser
;
import
fi.insomnia.bortal.web.cdiview.GenericCDIView
;
...
...
@@ -77,6 +85,12 @@ public class UserView extends GenericCDIView {
private
transient
EventBeanLocal
eventbean
;
@EJB
private
transient
CardPrintBeanLocal
cardPrintBean
;
private
File
file
;
private
StreamedContent
streamedFile
;
private
MassPrintResult
mpr
=
null
;
private
boolean
waitForAcceptance
=
false
;
@Produces
@LoggedIn
...
...
@@ -143,6 +157,31 @@ public class UserView extends GenericCDIView {
}
return
null
;
}
public
void
prepareCardDownload
()
{
file
=
null
;
try
{
mpr
=
cardPrintBean
.
getUserCardAsPrintablePdf
(
this
.
user
.
getId
());
file
=
File
.
createTempFile
(
"cardprintout"
,
null
);
FileOutputStream
fostream
=
new
FileOutputStream
(
file
);
fostream
.
write
(
mpr
.
getPdf
());
fostream
.
close
();
setStreamedFile
(
new
DefaultStreamedContent
(
new
FileInputStream
(
this
.
file
)));
}
catch
(
Exception
e
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
e
.
getMessage
()));
}
}
public
String
acceptPrintedCard
()
{
if
(
mpr
!=
null
&&
mpr
.
getAffectedUsers
().
size
()
>
0
)
{
cardPrintBean
.
acceptMassPrintResult
(
mpr
);
return
"accepted"
;
}
else
{
return
"failure"
;
}
}
public
String
makeCard
()
{
...
...
@@ -311,4 +350,24 @@ public class UserView extends GenericCDIView {
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
void
raiseWaitForAcceptance
()
{
waitForAcceptance
=
true
;
}
public
boolean
isWaitForAcceptance
()
{
return
waitForAcceptance
;
}
public
void
setWaitForAcceptance
(
boolean
waitForAcceptance
)
{
this
.
waitForAcceptance
=
waitForAcceptance
;
}
public
StreamedContent
getStreamedFile
()
{
return
streamedFile
;
}
public
void
setStreamedFile
(
StreamedContent
streamedFile
)
{
this
.
streamedFile
=
streamedFile
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment