<div dir="ltr">Hi list.<div>I try to use CmsDefaultFileNameGenerator.getNewFileName(CmsObject cms, java.lang.String namePattern, int defaultDigits) </div><div>this method returns good new name for first folder (i tri to create folders)</div>
<div>but for second new name it returns the same name as first</div><div><br></div><div>opencms 8.5.2</div><div><br></div><div><br></div><div>jsp code:</div><div><div><%@ page buffer="none" session="false"%></div>
<div><%@ taglib prefix="cms" uri="<a href="http://www.opencms.org/taglib/cms">http://www.opencms.org/taglib/cms</a>" %></div><div><%@ taglib prefix="c" uri="<a href="http://java.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core</a>" %></div>
<div><%@ taglib prefix="fn" uri="<a href="http://java.sun.com/jsp/jstl/functions">http://java.sun.com/jsp/jstl/functions</a>" %></div><div><%@ taglib prefix="f" uri="<a href="http://java.sun.com/jsp/jstl/fmt">http://java.sun.com/jsp/jstl/fmt</a>" %></div>
<div><%@page import="</div><div><span class="" style="white-space:pre"> </span>java.util.*,</div><div><span class="" style="white-space:pre"> </span>java.text.DateFormat,</div><div><span class="" style="white-space:pre"> </span>org.opencms.jsp.*,</div>
<div><span class="" style="white-space:pre"> </span>org.opencms.file.CmsObject,</div><div><span class="" style="white-space:pre"> </span>org.opencms.jsp.util.CmsJspContentAccessBean,</div><div><span class="" style="white-space:pre"> </span>org.opencms.file.types.CmsResourceTypeFolder,</div>
<div><span class="" style="white-space:pre"> </span>org.opencms.loader.*,</div><div><span class="" style="white-space:pre"> </span>org.opencms.main.OpenCms,</div><div><span class="" style="white-space:pre"> </span>org.opencms.file.*,</div>
<div><span class="" style="white-space:pre"> </span>org.opencms.file.types.*,</div><div><span class="" style="white-space:pre"> </span>org.opencms.util.CmsRequestUtil,</div><div><span class="" style="white-space:pre"> </span>org.opencms.main.CmsException</div>
<div>"%></div><div><%</div><div><span class="" style="white-space:pre"> </span>CmsJspActionElement cmsa = new CmsJspActionElement(pageContext, request, response);</div><div><span class="" style="white-space:pre"> </span>CmsObject cmso = cmsa.getCmsObject();</div>
<div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>String act = cmsa.getRequest().getParameter("fact") == null ? "view" : cmsa.getRequest().getParameter("fact");</div>
<div><span class="" style="white-space:pre"> </span>String fText = request.getParameter("fText") == null ? "" : request.getParameter("fText");</div><div><span class="" style="white-space:pre"> </span>String fPath = request.getParameter("fPath") == null ? "/" : request.getParameter("fPath");</div>
<div><span class="" style="white-space:pre"> </span>String backURL = request.getParameter("backURL") == null ? "/" : request.getParameter("backURL");</div><div><span class="" style="white-space:pre"> </span></div>
<div><span class="" style="white-space:pre"> </span></div><div>if( !cmso.getRequestContext().currentUser().isGuestUser() ){</div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>List properties = new ArrayList();</div>
<div><span class="" style="white-space:pre"> </span>properties.add(new CmsProperty("Title", fText, null));</div><div><span class="" style="white-space:pre"> </span>properties.add(new CmsProperty("NavText", fText, null));</div>
<div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>if( act.equals("new") ){</div><div><span class="" style="white-space:pre"> </span>CmsDefaultFileNameGenerator defaultGenerator = new CmsDefaultFileNameGenerator();</div>
<div><span class="" style="white-space:pre"> </span>String fName = defaultGenerator.getNewFileName(cmso, fPath + "f%(number)", 6);</div><div><span class="" style="white-space:pre"> </span>out.println("fName="+fName);</div>
<div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>CmsResourceManager res_manager = OpenCms.getResourceManager();</div><div><br></div><div><span class="" style="white-space:pre"> </span>cmso.createResource(fName, res_manager.getResourceType("folder").getTypeId(), null, properties);</div>
<div><span class="" style="white-space:pre"> </span>cmso.createResource(fName+"/index.html", res_manager.getResourceType("IndexHtml").getTypeId(), null, null);</div><div><span class="" style="white-space:pre"> </span></div>
<div><span class="" style="white-space:pre"> </span>}else if( act.equals("save") ){</div><div><span class="" style="white-space:pre"> </span>cmso.lockResource(fPath); </div><div> cmso.writePropertyObjects(fPath, properties); </div>
<div> cmso.unlockResource(fPath); </div><div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>//org.opencms.util.CmsRequestUtil.redirectRequestSecure(cmsa, backURL);</div>
<div>}</div><div>%></div></div><div><br></div><div><br></div><div><br></div><div><br></div></div>