HIPPO CMS表单呈现需要浏览器重新加载

时间:2018-09-26 02:18:42

标签: hippocms

我目前正在河马 CommonComponent 上使用河马Forms Rendering https://www.onehippo.org/library/concepts/component-development/hst-2-forms.html,我具有以下代码,因此我可以将消息传递给模板引擎,以在< strong> doBeforeRender

   @Override
    public void doBeforeRender(HstRequest request, HstResponse response) {
        super.doBeforeRender(request, response);

        HippoBean scope = request.getRequestContext().getSiteContentBaseBean();
        loadValueList(request, scope);

        FormMap map = FormUtils.getFormMap(request);
        if(map.getMessage().isEmpty()){
            map = FormUtils.getFormMap(request);
        }

        Optional<String> result = Optional.ofNullable(map.getMessage().get(REGISTER_RESULT));
        Optional<String> message = Optional.ofNullable(map.getMessage().get(REGISTER_RESULT_MESSAGE));
        request.setAttribute(REGISTER_RESULT, result.isPresent() ? Boolean.valueOf(result.get()) : StringUtils.EMPTY);
        request.setAttribute(REGISTER_RESULT_MESSAGE, message.isPresent() ? message.get() : StringUtils.EMPTY);
        map.setSealed(true);
    }

    @Override
    public void doAction(HstRequest request, HstResponse response) throws HstComponentException {
        super.doBeforeRender(request, response);

        FormMap map = getFormMapFields(request);
        GenericRestResponse result;
        try{
            UserRegistrationProfileDTO profile = UserRegistrationProfileDTO.ofWithCheckFiles(map);
            result = userAPIClient.requestUserCreationWithoutCredentials(profile);
        }catch (IllegalArgumentException ex){
            result = GenericRestResponse.builder().success(false).message(ex.getMessage()).build();
        }
        map.addMessage(REGISTER_RESULT, String.valueOf(result.isSuccess()));
        map.addMessage(REGISTER_RESULT_MESSAGE, String.valueOf(result.getMessage()));
        FormUtils.persistFormMap(request, response, map, null);
    }

问题是,当服务器使用GET方法使用重定向到表单原始URL的形式响应表单的POST请求时,表单消息不存在,我需要重新加载页面(ctrl + R)才能获取消息。

¿任何可能导致此行为的线索?

对于有关此行为的任何建议,我将不胜感激

0 个答案:

没有答案