我有JSP页面,提供文件夹的表树视图。这些文件夹是JSON <s:iterator ... >
文件夹包含plan.pdf,它们也是<s:iterator
示例:
Root
Folder1
plan1.pdf
plan2.pdf
subFolder1.1
plan1.pdf
subFolder1.2
plan1.pdf
Folder2
plan1.pdf
现在我拖动Folder1.2并粘贴到Folder1.1 ..树视图将变为:
- Root
- Folder1
- plan1.pdf
- plan2.pdf
- subFolder1.1
- plan1.pdf
- subsubFolder1.1.2
- plan1.pdf
有什么建议吗?
你也知道如何以这个
显示树视图- Root
- |--- Folder 1
- | |--- subFolder 1.1
- | |--- subFolder 1.2
- |--- Folder 2
- | |--- subFolder 2.1
- |--- Folder 3
- | |--- subFolder 3.1
代码:
Class PlanFolder
@Entity
@Table(name="plan_folder")
public class PlanFolder extends EntiteSynchroniseeAbstract implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="plan_folder_id")
private int planFolderId;
//bi-directional many-to-one association to Projet
@ManyToOne
@JoinColumn(name="project_id")
private Projet projet;
//bi-directional One To One association to PlanFolder
@OneToOne
@JoinColumn(nullable=true, name="root_id")
private PlanFolder root;
@Column(name="plan_folder_name")
private String planFolderName;
//bi-directional many-to-one association to Plan
@OneToMany(mappedBy="folder")
private List<Plan> plans;
//setters and getters
DAO接口
public interface DaoPlanFolder extends Dao<PlanFolder> {
public List<PlanFolder> getPlanFolders(int projetId);
public void deleteFolder(int planfolderId);
public PlanFolder getRacine (int projetId);
public List<PlanFolder> verifiePlanFolder (int projetId, int planId, String planFolderName);
public void moveFolder (int planfolderId , int newRootId );
public void renameFolder (int planfolderId , String newName);
public PlanFolder createFolder(String name, int projetId, int rootId , int planId);
public Fichier telechargeMiniature(int projetId);
public List<Plan> getPlans(int projetId, int folderId);
public Fichier chargerFichierCompressed(Fichier archive , int projetId, Utilisateur utilisateur, File source);
public void deleteByIdPlanFolder (int planFolderId) ;
public PlanFolder createRacine(String name, int projetId);
}
动作
public String movePlanFolder() {
DaoPlanFolder daoPlanFolder = DaoFactory.getDaoPlanFolder();
daoPlanFolder.moveFolder(this.planFolderId, this.rootId);
daoPlanFolder.close();
return SUCCESS;
}
JSP
<s:if test="planFolders.size > 0">
<table id="table_planFolders" class="table_datas">
<tr>
<th class="largeur_5"></th>
<th class="largeur_5"></th>
<th class="largeur_25"></th>
<th class="largeur_25"></th>
<th><s:text name="plans.th.nom"/></th>
<th class="largeur_100"><s:text name="plans.th.indice"/></th>
<th class="largeur_100"><s:text name="plans.th.echelle"/></th>
<th class="largeur_160"></th>
</tr>
<tr>
<td colspan="8">
<div class="separateur"></div>
</td>
</tr>
<s:iterator value="planFolders" status="status">
<tr id="${planFolderId}" class="${status.even ? 'tr_paire' : ''}">
<td onclick="<s:set var="rootId" value="rootId"/>">
<s:if test="rootId != 0">
<ul>
<li>
<c:set var="plus" value="${pageContext.servletContext.contextPath}/css/elements/plus.png" scope="request"/>
<s:submit type="image" src="%{#request.plus}" onclick="createPlanFolder('%{planFolderName}','%{planFolderId}',0)"/>
</li>
<li>
<c:set var="main" value="${pageContext.servletContext.contextPath}/css/elements/main.png" scope="request"/>
<s:submit type="image" src="%{#request.main}" onclick="deplacePlanFolder('%{planFolderId}','%{rootId}')"/>
</li>
</ul>
</s:if></td>
<td>
<table><tr><td>
<s:if test="rootId != 0">
<s:if test="'%{planFolders[counter].rootId}'!='%{racineId}'">
<script type="text/javascript">document.write(traitdebase);</script>
</s:if>
</s:if></td> <td>
<input type="image" src="<%=request.getContextPath()%>/css/elements/repertoire.png" height="42" width="42">
</td></tr></table>
</td>
<td>
<h2>${planFolderName}</h2>
</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>
<s:if test="rootId != 0">
<ul>
<li class="lien" onclick="renamePlanFolder(${planFolderId})"><s:text name="planFolder.lien.RenameFolder"/></li>
<li class="lien" onclick="deletePlanFolder(${planFolderId})"><s:text name="planFolder.lien.DeleteFolder"/></li>
</ul>
</s:if>
</td>
</tr>
<tr>
<s:if test="plans.size > 0">
<tr>
<td colspan="8">
<div class="separateur"></div>
</td>
</tr>
<s:iterator value="plans" status="status">
<tr class="${status.even ? 'tr_paire' : ''}">
<td>
<ul>
<li>
<c:set var="plus" value="${pageContext.servletContext.contextPath}/css/elements/plus.png" scope="request"/>
<s:submit type="image" src="%{#request.plus}" onclick="createPlanFolder('%{planNom}','%{planFolderId}','%{planId}')"/>
</li>
<li>
<c:set var="main" value="${pageContext.servletContext.contextPath}/css/elements/main.png" scope="request"/>
<s:submit type="image" src="%{#request.main}" />
</li>
</ul>
</td>
<td>
<s:if test="'%{planFolders[counter].rootId}'!='%{racineId}'">
<script type="text/javascript">document.write(traitdeplan);</script>
</s:if>
</td>
<td></td>
<td>
<s:if test="indiceActuel.indiceStatut == 2">
<img class="pointeur" src="TelechargeMiniature.bp?indiceId=${indiceActuel.indiceId}" align="middle" onclick="affichePlan(${planId})" />
</s:if>
<s:elseif test="indiceActuel.indiceStatut == 3">
<s:text name="plans.message.error"/>
</s:elseif>
<s:else>
<s:text name="plans.message.enCours"/>
</s:else>
</td>
<td><b>${planNom}</b></td>
<td>${indiceActuel.indiceNumero}</td>
<td><s:text name="enum.echelle.%{indiceActuel.echelleEnum}" /></td>
<td>
<ul>
<li class="lien" onclick="augmenterIndice(${planId})" ><s:text name="plans.lien.nouvelIndice"/></li>
<li class="lien" onclick="modifierPlan(${planId})"><s:text name="plans.lien.modifierPlan"/></li>
<li class="lien" onclick="supprimerIndice(${planId})"><s:text name="plans.lien.supprimerIndice"/></li>
</ul>
</td>
</tr>
</s:iterator>
</s:if>
</tr ><script type="text/javascript">counter = counter+1;</script>
</s:iterator>
</table>
</s:if>
我们的客户有一个场景,我把它作为图像 - 他想通过点击手将手变成橙色,这意味着这是我想要移动的文件夹selection。
之后点击另一个文件夹,该文件夹变为蓝色选择,表示这个新的根目的地({3}}。
我想把它作为一个拖放行来复杂化。