Forums

Home » Alloy UI » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
Madasamy P
alert message not displayed in ajax
December 29, 2016 11:12 PM
Answer

Madasamy P

Rank: Junior Member

Posts: 66

Join Date: July 27, 2016

Recent Posts

This is my script

<script>
function submitForm(){
$.ajax({
type : "GET",
url: "renderURL.toString()",
dataType : 'json',

success : function(){
alert('TreeView');
}

});
}

And my class submission.java

public void doView(RenderRequest renderRequest,
RenderResponse renderResponse) throws IOException, PortletException {
// TODO Auto-generated method stub
generateTreeViewFromSourceFile(renderRequest,renderResponse);
super.doView(renderRequest, renderResponse);
}

public void generateTreeViewFromSourceFile(RenderRequest renderRequest,
RenderResponse renderResponse){
System.out.println("Checking..........");
long parentFolderId = 0;
List<TreeView> treeViewList = new ArrayList<TreeView>();

ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = themeDisplay.getLayout().getGroupId();
int fileEntryStatus = WorkflowConstants.STATUS_APPROVED;

try {
DLFolder folder = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, PRODUCTION_FOLDER_NAME);

// Fetching all source xhtml files from xhtml folder
List<DLFileEntry> dlFileEntries = DLFileEntryLocalServiceUtil.getFileEntries(groupId, parentFolderId, fileEntryStatus, -1, -1, null);

for(DLFileEntry dlFileEntry : dlFileEntries){

FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(dlFileEntry.getFileEntryId());
FileVersion fileVersion = fileEntry.getFileVersion();

String url = DLUtil.getPreviewURL(fileEntry, fileVersion, themeDisplay, "");
String title = dlFileEntry.getTitle();
String treeId = title.replaceAll(" ", "_").toLowerCase();
treeId = treeId.replaceAll("\\.","_");

// Creating TreeView model for each tree
TreeView treeView = new TreeView();
treeView.setId(treeId);
treeView.setTitle(title);
treeView.setSourceURL(url);

// If file name matches with 'destination', it will be treated as a destination tree source file
if(!(title.toLowerCase().contains("destination"))){
treeViewList.add(treeView);
} else{
renderRequest.setAttribute("destTreeView", treeView);
}

}

List<String> styleNodeNameList = getListOfStyleName();
renderRequest.setAttribute("styleNameList", styleNodeNameList);
renderRequest.setAttribute("treeViewList", treeViewList);

} catch (PortalException | SystemException e) {
e.printStackTrace();
}

}

The ajax URL directly calls the generateTreeViewFromSourceFile method and it completely executed
But on success function in ajax not displays the alert('TreeView') message .