Author: andre
Date: 2010-06-11 12:21:58 +0200 (Fri, 11 Jun 2010)
New Revision: 42520

Added:
   openimages/trunk/src/main/webapp/action/favorite.jspx
Log:
to add/remove favorites using an ajax call


Added: openimages/trunk/src/main/webapp/action/favorite.jspx
===================================================================
--- openimages/trunk/src/main/webapp/action/favorite.jspx                       
        (rev 0)
+++ openimages/trunk/src/main/webapp/action/favorite.jspx       2010-06-11 
10:21:58 UTC (rev 42520)
@@ -0,0 +1,68 @@
+<jsp:root
+    version="2.0"
+    xmlns:c="http://java.sun.com/jsp/jstl/core";
+    xmlns:jsp="http://java.sun.com/JSP/Page";
+    xmlns:mm="http://www.mmbase.org/mmbase-taglib-2.0";>
+    
+  <mm:content 
+      type="application/xml"
+      postprocessor="none"
+      expires="0">
+    <jsp:output omit-xml-declaration="true" />
+    
+    <mm:cloud method="asis">
+      <mm:maycreate type="ratingrel">
+        
+        <mm:import externid="favorite" />
+        <mm:import externid="remove" />
+        <mm:import externid="user"><mm:cloudinfo type="usernode" /></mm:import>
+        
+        <mm:node number="$favorite" notfound="skip">
+          <mm:nodeinfo type="type" id="type" write="false" />
+          <c:if test="${type eq 'mediafragments' or type eq 'videofragments' 
or type eq 'audiofragments' or type eq 'imagefragments'}">
+            <!-- from mmbaseusers to media -->
+            <mm:listrelationscontainer type="mmbaseusers" role="ratingrel" 
searchdir="source">
+              <mm:constraint field="ratingrel.snumber" value="$user" 
operator="EQUAL" />
+              <mm:listrelations>
+                <mm:node id="favrel" /> <c:set var="favselected" 
value="selected" />
+              </mm:listrelations>
+            </mm:listrelationscontainer>
+          </c:if>
+        </mm:node>
+        
+        <c:if test="${!empty favorite}">
+          
+          <c:if test="${empty favrel}">
+            <mm:node number="$favorite" id="newfav">
+              <mm:listrelationscontainer type="mmbaseusers" role="ratingrel" 
searchdir="source">
+                <mm:constraint field="ratingrel.snumber" value="$user" 
operator="EQUAL" />
+                <mm:listrelations>
+                  <mm:node id="favrel" />
+                </mm:listrelations>
+              </mm:listrelationscontainer>
+            </mm:node>
+          </c:if>
+          
+          <c:if test="${empty remove and empty favrel}">
+            <mm:createrelation source="user" destination="newfav" 
role="ratingrel" />
+            <c:set var="favselected" value="selected" />
+              <p class="msg">This media item has been selected as a 
favorite.</p>
+          </c:if>
+          <c:if test="${!empty remove and !empty favrel}">
+            <mm:deletenode referid="favrel" />
+            <c:set var="favselected" value="" />
+              <p class="msg">Your favorite selection is removed.</p>
+          </c:if>
+        </c:if> 
+      
+        <p class="msg">Sorry, nix gebeurd.</p>
+      </mm:maycreate>
+      
+      <mm:maycreate type="ratingrel" inverse="true">
+        <p class="err">Not allowed.</p>
+      </mm:maycreate>
+    
+    </mm:cloud>
+    
+  </mm:content>
+</jsp:root>

_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to