我仍在尝试访问存储库以添加新用户。我的组件连接到侧面,并且我在 FormMap 中有所有需要的值。
问题是我不知道该怎么做。在我最后一个问题在 Hippo cms 中注册用户时,我得到了我需要将组件连接到 /hippo:configuration/hippo:users 的答案。
怎么做?
这是我的实际组件:
package org.example.components;
import javax.jcr.Session;
import org.hippoecm.hst.component.support.bean.BaseHstComponent;
import org.hippoecm.hst.core.component.HstComponentException;
import org.hippoecm.hst.core.component.HstRequest;
import org.hippoecm.hst.core.component.HstResponse;
import org.hippoecm.hst.component.support.forms.FormMap;
import org.hippoecm.hst.component.support.forms.FormUtils;
import org.hippoecm.hst.component.support.forms.FormField;
import org.hippoecm.hst.content.annotations.Persistable;
import org.hippoecm.hst.content.beans.Node;
import org.hippoecm.hst.content.beans.standard.HippoFolderBean;
public class SignUpComponent extends BaseHstComponent {
@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
super.doBeforeRender(request, response);
}
@Persistable
@Override
public void doAction(HstRequest request, HstResponse response) throws HstComponentException {
FormMap map = new FormMap(request, new String[]{"username","email","password"});
FormField username = map.getField("username");
FormField password = map.getField("password");
FormField email = map.getField("email");
try {
// NOTE: This session will be logged out automatically in the normal HST request processing thread.
Session persistableSession = request.getRequestContext().getSession();
} catch (Exception e) {
}
Node users = persistableSession.getNode("/hippo:configuration/hippo:users");
}
虽然导入节点不起作用
error: cannot find symbol
我也试过
Node users = getSiteContentBaseBean(request).getNode().getSession().getRootNode().getNode("/hippo:configuration/hippo:users");