01: /*
02: * de.schlund.pfixcore.example.EncodingTestState
03: */
04: package de.schlund.pfixcore.example;
05:
06: import javax.servlet.http.HttpServletRequest;
07:
08: import de.schlund.pfixcore.workflow.Context;
09: import de.schlund.pfixcore.workflow.app.DefaultIWrapperState;
10: import de.schlund.pfixxml.PfixServletRequest;
11: import de.schlund.pfixxml.ResultDocument;
12: import de.schlund.pfixxml.util.URIParameters;
13:
14: /**
15: * EncodingTestState.java
16: *
17: * Created: 25.11.2004
18: *
19: * @author mleidig
20: */
21: public class EncodingTestState extends DefaultIWrapperState {
22:
23: public boolean isAccessible(Context context, PfixServletRequest preq)
24: throws Exception {
25: return true;
26: }
27:
28: public ResultDocument getDocument(Context context,
29: PfixServletRequest req) throws Exception {
30: HttpServletRequest srvReq = req.getRequest();
31: String enc = srvReq.getCharacterEncoding();
32: ContextEncodingTest ctxEnc = (ContextEncodingTest) context
33: .getContextResourceManager().getResource(
34: ContextEncodingTest.class.getName());
35: ctxEnc.setEncoding(enc);
36: String encoding = srvReq.getParameter("text.Encoding");
37: if (encoding != null && encoding.trim().length() > 0
38: && !encoding.equals("none")) {
39: URIParameters params = new URIParameters(srvReq, encoding);
40: String val = params.getParameter("text.Text");
41: ctxEnc.setText(val);
42: }
43: return super.getDocument(context, req);
44: }
45:
46: }
|