Sunday 31 March 2019

Dynamic Attribute

The following example shows the configuration of the Dynamic Attribute in the items.xml file:

<itemtype code="Accommodation" autocreate="true" generate="true" jaloclass="de.hybris.platform.test.Accommodation">
<attributes>
                <!-- ... -->
                <attribute type="java.lang.String" qualifier="daysHumanReadable">
                <persistence type="dynamic" attributeHandler="accommodationDays" />
                <modifiers read="true" write="false" />
                </attribute>
                <!-- ... -->
</attributes>
</itemtype>

AccommodationDays.java


public class AccommodationDays implements DynamicAttributeHandler<String, AccommodationModel>
{

 @Override
 public String get(final AccommodationModel model)
 {
                String daysWord;
  final int days = model.getDays();
                if (days == 1)
                {
                       daysWord = "day";
                } 
                else
                {
                       daysWord = "days";
                }
                return days + " " + daysWord;
 }

 @Override
 public void set(final AccommodationModel model, final String value)
 {
  throw new UnsupportedOperationException();
 }

}


It is recommended to implement the above method to throw an exception, because the write modifier of the daysHumanReadable attribute is set to false. Thus there is no setter generated in the AccommodationModel.

we can get the value based on some business logic.

SAP WCMS (Web Content Management System)

Web content management module is used for the management of content across multiple channels. The WCMS Cockpit provides a simple way for cockpit users to manage their website pages. It provides an intuitive, graphical user interface for data presentation and management. The WCMS Cockpit also supports workflow and synchronization tasks.


WCMS Module Extensions
WCMS Cockpit  works on CMSCockpit extension. The WCMS Cockpit, you can manage the pages of a website constructed using the CMS2 extension. You can also use the extended components included in the CMS2Lib extension to manage the website pages
The WCMS Cockpit contains the following areas −
Navigation AreaOn the left hand side, you have the navigation pane, where you can navigate to Shortcuts, Queries, Websites and the History tab
*History Box: Last 20 transactions we can undo.
*Info Box: workflow tasks assigned to you
*Queries: 

Browser Area : In the center, you have the Browser area, which is used to manage web content for all the channels. You can add Top Header, Bottom Header and Footer
Content Editor Area:
On the right hand side, you have the Cockpit area. The following options are available under the Editor area in the Basic Category −
  • Name
  • Page title
  • Page Template
  • Catalog Version
  • Label
  • Homepage, etc

Hybris miscellaneous topics

1) How to add message property with css

JSP:
<formElement:formCheckbox idKey="add-mycompany-checkbox" labelCSS="checkbox-wrapper m-b-1" labelKey="mycompany.select.termsandconditions"  path="termsAndConditions" mandatory="true" />

base.properties
mycompany.select.termsandconditions = <span class="checkbox-text ma-label-font">I confirm that the information I have provided is accurate, and I agree to Mycompany <a class="a-link" target="_blank" href="https://www.mycompany.govt.nz/Pages/terms-and-conditions.aspx"> terms and conditions </a> and <a class="a-link" target="_blank" href="https://www.mycompany.govt.nz/Pages/privacy-policy.aspx"> privacy policy</a>. </span>


2)  How to add Dynamic parameters
jsp:
<spring:theme code="mycompany.property.invalid.attempts.count.max.message" arguments="${jalosession.tenant.config.getParameter('mycompany.max.failed.attempts.count')} ,${jalosession.tenant.config.getParameter('mycompany.max.failed.attempts.hour')}" htmlEscape="false"></spring:theme>

base.properties
mycompany.property.invalid.attempts.count.max.message=<h5 class="ma-h5"> Account locked</h5><p>You have entered the incorrect number and PIN combination {0} times. You will not be able to add another property for {1} hours.</p>


3) How to read property key in jsp

<spring:theme code="mycompany.property.invalid.attempts.count.max.message" arguments="${jalosession.tenant.config.getParameter('mycompany.max.failed.attempts.count')} ,${jalosession.tenant.config.getParameter('mycompany.max.failed.attempts.hour')}" htmlEscape="false"></spring:theme>

mycompany.max.failed.attempts.count key defined in project.properties or base.properties

4) How to check anonymous customer in jsp
jalosession.attributes['user'].anonymousCustomer

5) Delete typecode from deployment table - same typecode for multiple items ( old one removed but still in deployment table)

DELETE FROM <YOUR DB NAME>.ydeployments WHERE Typecode=18001(deployment code);

change the development code what ever you have conflicts in my case its 18001 is the conflicting deployment code.