Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bd7bc9b5
authored
Oct 31, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asdasd
1 parent
ff81526e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
158 additions
and
87 deletions
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollAnswer.java
code/LanBortalWeb/WebContent/poll/answerToPoll.xhtml
code/LanBortalWeb/WebContent/poll/start.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/view/PollView.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/helpers/PollWrapper.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollAnswer.java
View file @
bd7bc9b
...
@@ -41,8 +41,9 @@ public class PollAnswer extends GenericEventChild implements Serializable {
...
@@ -41,8 +41,9 @@ public class PollAnswer extends GenericEventChild implements Serializable {
super
();
super
();
}
}
public
PollAnswer
(
PollQuestion
q
)
{
public
PollAnswer
(
PossibleAnswer
a
)
{
super
(
new
EventPk
(
q
.
getId
().
getId
()));
super
(
new
EventPk
(
a
.
getId
().
getId
()));
this
.
choice
=
a
;
}
}
public
String
getAnswerText
()
{
public
String
getAnswerText
()
{
...
...
code/LanBortalWeb/WebContent/poll/answerToPoll.xhtml
0 → 100644
View file @
bd7bc9b
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.eventorg.list"
/>
<ui:define
name=
"content"
>
<h:form
id=
"answerForm"
>
<h:dataTable
border=
"1"
id=
"questions"
value=
"#{pollView.currentPage}"
var=
"question"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['poll.name']}"
/>
</f:facet>
<h:outputText
value=
"#{question.question.question}"
/>
</h:column>
<h:column>
<h:inputText
rendered=
""
</
h:column
>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/poll/start.xhtml
0 → 100644
View file @
bd7bc9b
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.eventorg.list"
/>
<ui:define
name=
"content"
>
#{pollView.initPollList()}
<h:form>
<h:dataTable
border=
"1"
id=
"maps"
value=
"#{pollView.polls}"
var=
"poll"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['poll.name']}"
/>
</f:facet>
<h:outputText
value=
"#{poll.name}"
/>
</h:column>
<h:column>
<h:commandButton
action=
"#{pollView.beginPoll()}"
value=
"#{i18n['poll.answer']}"
/>
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/src/fi/insomnia/bortal/view/PollView.java
View file @
bd7bc9b
package
fi
.
insomnia
.
bortal
.
view
;
package
fi
.
insomnia
.
bortal
.
view
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.SessionScoped
;
import
javax.faces.bean.SessionScoped
;
...
@@ -7,7 +12,9 @@ import javax.faces.model.ListDataModel;
...
@@ -7,7 +12,9 @@ import javax.faces.model.ListDataModel;
import
fi.insomnia.bortal.beans.PollBeanLocal
;
import
fi.insomnia.bortal.beans.PollBeanLocal
;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.view.helpers.PollWrapper
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PollQuestion
;
import
fi.insomnia.bortal.model.PossibleAnswer
;
@ManagedBean
(
name
=
"pollView"
)
@ManagedBean
(
name
=
"pollView"
)
@SessionScoped
@SessionScoped
...
@@ -16,22 +23,100 @@ public class PollView extends GenericView {
...
@@ -16,22 +23,100 @@ public class PollView extends GenericView {
@EJB
@EJB
private
PollBeanLocal
pollBean
;
private
PollBeanLocal
pollBean
;
private
PollWrapper
pollwrapper
;
private
ListDataModel
<
Poll
>
polls
;
private
ListDataModel
<
Poll
>
polls
;
private
HashMap
<
Integer
,
List
<
QuestionWrapper
>>
pages
;
private
Integer
thisPage
=
1
;
public
void
initPollList
()
{
public
void
initPollList
()
{
polls
=
new
ListDataModel
<
Poll
>(
pollBean
.
findPolls
());
setPolls
(
new
ListDataModel
<
Poll
>(
pollBean
.
findPolls
()));
}
public
String
nextPage
()
{
++
thisPage
;
return
null
;
}
public
List
<
QuestionWrapper
>
getCurrentPage
()
{
return
pages
.
get
(
thisPage
);
}
}
public
String
beginPoll
()
{
public
String
beginPoll
()
{
pollwrapper
=
new
PollWrapper
(
polls
.
getRowData
());
thisPage
=
1
;
return
"showPoll"
;
Poll
poll
=
polls
.
getRowData
();
pages
=
new
HashMap
<
Integer
,
List
<
QuestionWrapper
>>();
for
(
PollQuestion
q
:
poll
.
getQuestions
())
{
if
(!
pages
.
containsKey
(
q
.
getPage
()))
{
pages
.
put
(
q
.
getPage
(),
new
LinkedList
<
QuestionWrapper
>());
}
pages
.
get
(
q
.
getPage
()).
add
(
new
QuestionWrapper
(
q
));
}
return
"/poll/answerToPoll"
;
}
}
public
String
savePoll
()
{
public
String
savePoll
()
{
if
(
pollwrapper
.
validate
(
this
))
{
if
(
validate
(
this
))
{
pollBean
.
createAnswers
(
pollwrapper
.
get
Answers
());
pollBean
.
createAnswers
(
create
Answers
());
}
}
return
"thankYou"
;
return
"thankYou"
;
}
}
public
void
setPolls
(
ListDataModel
<
Poll
>
polls
)
{
this
.
polls
=
polls
;
}
public
ListDataModel
<
Poll
>
getPolls
()
{
return
polls
;
}
private
List
<
PollAnswer
>
createAnswers
()
{
ArrayList
<
PollAnswer
>
ret
=
new
ArrayList
<
PollAnswer
>();
for
(
List
<
QuestionWrapper
>
qw
:
pages
.
values
())
{
for
(
QuestionWrapper
wrapper
:
qw
)
{
ret
.
addAll
(
wrapper
.
getAnswers
());
}
}
return
ret
;
}
public
boolean
validate
(
PollView
pollView
)
{
boolean
ret
=
true
;
return
ret
;
}
public
class
QuestionWrapper
{
private
PollQuestion
question
;
private
ArrayList
<
PollAnswer
>
answers
;
public
QuestionWrapper
(
PollQuestion
q
)
{
question
=
q
;
answers
=
new
ArrayList
<
PollAnswer
>();
for
(
PossibleAnswer
possible
:
q
.
getAnswers
())
{
answers
.
add
(
new
PollAnswer
(
possible
));
}
}
public
PollQuestion
getQuestion
()
{
return
question
;
}
public
void
setQuestion
(
PollQuestion
question
)
{
this
.
question
=
question
;
}
public
void
setAnswers
(
ArrayList
<
PollAnswer
>
answers
)
{
this
.
answers
=
answers
;
}
public
ArrayList
<
PollAnswer
>
getAnswers
()
{
return
answers
;
}
}
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/view/helpers/PollWrapper.java
deleted
100644 → 0
View file @
ff81526
package
fi
.
insomnia
.
bortal
.
view
.
helpers
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
javax.faces.model.ListDataModel
;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PollQuestion
;
import
fi.insomnia.bortal.view.PollView
;
import
fi.insomnia.bortal.view.helpers.PollWrapper.QuestionWrapper
;
public
class
PollWrapper
{
HashMap
<
Integer
,
List
<
QuestionWrapper
>>
pages
;
public
PollWrapper
(
Poll
poll
)
{
pages
=
new
HashMap
<
Integer
,
List
<
QuestionWrapper
>>();
for
(
PollQuestion
q
:
poll
.
getQuestions
())
{
if
(!
pages
.
containsKey
(
q
.
getPage
()))
{
pages
.
put
(
q
.
getPage
(),
new
LinkedList
<
QuestionWrapper
>());
}
pages
.
get
(
q
.
getPage
()).
add
(
new
QuestionWrapper
(
q
));
}
}
public
class
QuestionWrapper
{
private
PollQuestion
question
;
private
PollAnswer
answer
;
public
QuestionWrapper
(
PollQuestion
q
)
{
question
=
q
;
answer
=
new
PollAnswer
(
q
);
}
public
PollQuestion
getQuestion
()
{
return
question
;
}
public
void
setQuestion
(
PollQuestion
question
)
{
this
.
question
=
question
;
}
public
PollAnswer
getAnswer
()
{
return
answer
;
}
public
void
setAnswer
(
PollAnswer
answer
)
{
this
.
answer
=
answer
;
}
}
public
List
<
PollAnswer
>
getAnswers
()
{
ArrayList
<
PollAnswer
>
ret
=
new
ArrayList
<
PollAnswer
>();
for
(
List
<
QuestionWrapper
>
qw
:
pages
.
values
())
{
for
(
QuestionWrapper
wrapper
:
qw
)
{
ret
.
add
(
wrapper
.
getAnswer
());
}
}
return
ret
;
}
public
boolean
validate
(
PollView
pollView
)
{
boolean
ret
=
true
;
return
ret
;
}
}
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