Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
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 3c16842b
authored
Oct 31, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pooooooollllll
1 parent
4d3aef6b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
3 deletions
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PollBeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollAnswer.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollQuestion.java
code/LanBortalWeb/WebContent/poll/answerToPoll.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/view/PollView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/PollAnswerConverter.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PollBeanLocal.java
View file @
3c16842
...
@@ -5,6 +5,7 @@ import javax.ejb.Local;
...
@@ -5,6 +5,7 @@ import javax.ejb.Local;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PossibleAnswer
;
@Local
@Local
public
interface
PollBeanLocal
{
public
interface
PollBeanLocal
{
...
@@ -14,4 +15,7 @@ public interface PollBeanLocal {
...
@@ -14,4 +15,7 @@ public interface PollBeanLocal {
boolean
createAnswers
(
List
<
PollAnswer
>
answers
);
boolean
createAnswers
(
List
<
PollAnswer
>
answers
);
PossibleAnswer
findPossibleAnwerById
(
int
id
);
}
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollAnswer.java
View file @
3c16842
...
@@ -50,7 +50,7 @@ public class PollAnswer extends GenericEventChild implements Serializable {
...
@@ -50,7 +50,7 @@ public class PollAnswer extends GenericEventChild implements Serializable {
return
answerText
;
return
answerText
;
}
}
public
void
setChoi
s
e
(
PossibleAnswer
choice
)
{
public
void
setChoi
c
e
(
PossibleAnswer
choice
)
{
this
.
choice
=
choice
;
this
.
choice
=
choice
;
}
}
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollQuestion.java
View file @
3c16842
...
@@ -41,7 +41,10 @@ public class PollQuestion extends GenericEventChild {
...
@@ -41,7 +41,10 @@ public class PollQuestion extends GenericEventChild {
public
String
getQuestion
()
{
public
String
getQuestion
()
{
return
question
;
return
question
;
}
}
public
boolean
isFreeText
()
{
return
(
answers
.
size
()
==
1
&&
answers
.
get
(
0
).
isText
());
}
public
void
setQuestion
(
String
question
)
{
public
void
setQuestion
(
String
question
)
{
this
.
question
=
question
;
this
.
question
=
question
;
}
}
...
...
code/LanBortalWeb/WebContent/poll/answerToPoll.xhtml
View file @
3c16842
...
@@ -18,7 +18,11 @@
...
@@ -18,7 +18,11 @@
<h:outputText
value=
"#{question.question.question}"
/>
<h:outputText
value=
"#{question.question.question}"
/>
</h:column>
</h:column>
<h:column>
<h:column>
<h:inputText
rendered=
""
<h:inputTextarea
cols=
"50"
rows=
"7"
value=
"#{question.textAnswer.answerText}"
rendered=
"#{question.freeText}"
/>
<h:selectOneRadio
converter=
"#{pollAnswerConverter}"
rendered=
"#{!question.freeText and question.choices eq 1}"
value=
"#{question.oneSelected}"
>
<f:selectItems
var=
"ans"
itemLabel=
"#{ans.choice.answer}"
value=
"#{question.answers}"
/>
</h:selectOneRadio>
</h:column>
</h:column>
</h:dataTable>
</h:dataTable>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/PollView.java
View file @
3c16842
...
@@ -101,6 +101,37 @@ public class PollView extends GenericView {
...
@@ -101,6 +101,37 @@ public class PollView extends GenericView {
}
}
public
boolean
isFreeText
()
{
return
question
.
isFreeText
();
}
public
PollAnswer
getTextAnswer
()
{
if
(!
isFreeText
())
{
throw
new
RuntimeException
(
"IS not freetext!! !!BUG!!BUG!!"
);
}
return
answers
.
get
(
0
);
}
public
void
setOneSelected
(
PollAnswer
ans
)
{
for
(
PollAnswer
possibleAns
:
answers
)
{
if
(
possibleAns
.
getChoice
().
equals
(
ans
.
getChoice
()))
{
possibleAns
.
setAnswerBoolean
(
true
);
}
else
{
possibleAns
.
setAnswerBoolean
(
false
);
}
}
}
public
PollAnswer
getOneSelected
()
{
for
(
PollAnswer
possibleAns
:
answers
)
{
if
(
possibleAns
.
getAnswerBoolean
())
{
return
possibleAns
;
}
}
return
null
;
}
public
PollQuestion
getQuestion
()
{
public
PollQuestion
getQuestion
()
{
return
question
;
return
question
;
}
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/PollAnswerConverter.java
0 → 100644
View file @
3c16842
package
fi
.
insomnia
.
bortal
.
web
.
converter
;
import
javax.ejb.EJB
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.NoneScoped
;
import
javax.faces.component.UIComponent
;
import
javax.faces.context.FacesContext
;
import
javax.faces.convert.Converter
;
import
fi.insomnia.bortal.beans.PollBeanLocal
;
import
fi.insomnia.bortal.beans.ProductBeanLocal
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PossibleAnswer
;
import
fi.insomnia.bortal.model.Product
;
@ManagedBean
(
name
=
"pollAnswerConverter"
)
@NoneScoped
()
public
class
PollAnswerConverter
implements
Converter
{
@EJB
private
PollBeanLocal
pollbean
;
public
PollAnswerConverter
()
{
}
@Override
public
Object
getAsObject
(
FacesContext
context
,
UIComponent
component
,
String
value
)
{
PossibleAnswer
possibleAnswer
=
pollbean
.
findPossibleAnwerById
(
Integer
.
parseInt
(
value
));
PollAnswer
ret
=
new
PollAnswer
();
ret
.
setChoice
(
possibleAnswer
);
return
ret
;
}
@Override
public
String
getAsString
(
FacesContext
context
,
UIComponent
component
,
Object
value
)
{
String
ret
=
null
;
if
(
value
instanceof
PollAnswer
)
{
ret
=
((
PollAnswer
)
value
).
getChoice
().
getId
().
getId
().
toString
();
}
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