Rev 1411 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package pt.estgp.estgweb.web.form.questionarios;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.QuestionarioResposta;
import pt.estgp.estgweb.domain.QuestionarioRespostaImpl;
import pt.estgp.estgweb.web.form.ApplicationForm;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jorgemachado on 05/06/16.
*/
public class QuestionarioRespostaForm
extends ApplicationForm
{
QuestionarioRespostaImpl resposta = DomainObjectFactory.
createQuestionarioRespostaImpl();
public QuestionarioRespostaForm
() {
resposta.
setQuestionario(DomainObjectFactory.
createQuestionarioImpl());
}
long alunoRequesitadoId
;
public long getAlunoRequesitadoId
() {
return alunoRequesitadoId
;
}
public void setAlunoRequesitadoId
(long alunoRequesitadoId
) {
this.
alunoRequesitadoId = alunoRequesitadoId
;
}
public QuestionarioRespostaImpl getResposta
() {
return resposta
;
}
public void setResposta
(QuestionarioRespostaImpl resposta
) {
this.
resposta = resposta
;
}
@
1.5.0/docs/api/java/lang/Override.html">Override
public ActionErrors validate
(ActionMapping mapping, HttpServletRequest request
) {
ActionErrors errors =
new ActionErrors
();
List
<String
> respostasVazias =
new ArrayList
<String
>();
for(int i =
1; i
<=
17; i++
)
{
try {
1.5.0/docs/api/java/lang/String.html">String r =
(1.5.0/docs/api/java/lang/String.html">String) QuestionarioResposta.
class.
getMethod("getR"+i
).
invoke(resposta
);
if(r ==
null || r.
trim().
length() == 0
)
{
if(respostasVazias.
size() ==
0)
addMessage
(errors, request,
"questionario.respostas.grupos.1.2.3");
respostasVazias.
add("" + i
);
}
}
catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e
)
{
1.5.0/docs/api/java/lang/System.html">System.
err.
println("Erro nao esperado metodo getR" + i +
" nao existe na resposta");
e.
printStackTrace();
}
}
if(respostasVazias.
size() > 0)
request.
setAttribute("respostasVazias",respostasVazias
);
return errors
;
}
}