Chuyển đến nội dung chính

Bài đăng

Đang hiển thị bài đăng từ Tháng 6, 2014

[RICHTEXT] Resize richtext height / width automatically when resize dialog / tab panel

Issue: Height of text area in RTE does not auto resize when dialog resizes. It is not possible to set the rich text height following the dialog height dynamically. Solution: Add listeners for dialog with bodyresize event <listeners jcr:primaryType="nt:unstructured" bodyresize="function(dialog, width, height) { if(dialog.getField("./richtextfield") != undefined) {dialog.getField("./richtextfield").el.parent().setStyle("height", (height-90)+"px");}}"/>

[COMPONENT] What is the automatically generated div tag around a component used for / How to remove DIV tag is generated by CQ

Question: If a component is included for example by the <cq:include> tag, a div tag is added automatically around the component in the generated HTML. What is this div tag used for and is it possible to suppress the automatic creation of it? Resolution: Add the below code in to global.jsp, which you include for all the component jsp's. if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN) {          IncludeOptions.getOptions(request, true).forceSameContext(Boolean.TRUE); } This will not generate any more extra <div> tags for any number of components you add. Reference: This div tag is used for the editing system of CQ5 (drawing the edit bars, rollover frames etc), the Designer system of CQ5 (set CSS class name, Designer CSS styling) and also for identifying the component in the client DOM. It's possible to suppress this generated div tag either by specifying an empty property cq:

[COMPONENT] Dialog validation in CQ5

Issue: How can I validate the data from the field of dialogue that cannot be handled with static constraints or regular expressions? Solution 1: Complex validation of CQ5 dialogue fields using a custom Sling servlet Dialog fields in CQ5 occasionally require validation that cannot be handled with static constraints or regular expressions. However, this type of validation can be easily accomplished by delegating the validation function to a custom servlet. The implementation details and code samples below describe a viable solution for most validation scenarios. Abstract Validation Servlet A project may require several dialogue validators, so it makes sense to abstract common functionality into a base class. This class is excerpted from the CITYTECH CQ5 library, which we offer to clients as a foundation package for new CQ5 projects. import java.io.IOException; import java.util.Collections; import javax.servlet.ServletException; import org.apache.sling.api.Slin