Skip to Content
author's profile photo Former Member
Former Member

Calling a bean in the backoffice view

I am trying to define a "create-wizard", some of the required values should be computed and not entered by the user/admin. One of these values is a code serving as a PK who is provided by a generator bean. I want to call the generate method of this bean in an assign element using the SPel syntax.

In my attempts to find a solution I have ssen that i can't use other beans, I have also found the bean "FixedBeanResolver" defined in backoffice who seems to list all available bean. I have tried making an other "FixedBeanResolver" containg the name of my generator bean and I've tried to implement a beanPostProcessor to add my bean to the "FixedBeanResolver".

Here is a snippet from the -backoffice-config.xml file.

 <context component="create-wizard" type="MyType">
 <wz:flow xmlns:wz="http://www.hybris.com/cockpitng/config/wizard-config"id="ProductWizard" title="create.product.title">
     <wz:prepare id="productPrepare">
         <wz:initialize property="newType" type="MyType"/>
         <wz:assign property="newType.code" value="@translationRequestCodeGenerator.generate()" />
         <wz:assign property="newType.emissionDate" value="new java.util.Date()"/>
     </wz:prepare>
         <wz:step id="step1" label="create.product.essential.label" sublabel="create.product.essential.sublabel">
             <wz:content id="step1.content">
                 <wz:property-list root="newType">
                     <wz:property qualifier="author" type="java.lang.String"/>
                     <wz:property qualifier="code" readonly="true" />
                     
                     ...
                     
                 </wz:property-list>
             </wz:content>
             <wz:navigation id="step1.navigation">
                 <wz:cancel/>
                 <wz:next visible="!#empty(newType.code)"/>
                 <wz:done visible="!#empty(newType.code)">
                     <wz:save property="newType"/>
                 </wz:done>
             </wz:navigation>
         </wz:step>
 </wz:flow>
 </context>
Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2016 at 02:49 PM

    Thanks to the answer of I found the class BeanPropertyExtender wich allowed me to solve my problem.

    The solution looks like this :

     <bean class="com.hybris.cockpitng.core.util.impl.BeanPropertyExtender" init-method="extend" destroy-method="clean" lazy-init="false">
         <property name="parentBean" ref="fixedBeanResolver"/>
         <property name="propertyName" value="availableBeanNames" />
         <property name="newValue" >
             <list>
                 <value>myBeanName</value>
                 <value>cockpitUserService</value>
             </list>
             </property>
     </bean>
    
    
    
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 02, 2018 at 02:35 PM

    Hi Guys,

    I've faced problem when tried to used bean in editor parameter value. And I've noticed that ListPropertyExtender is deprecated on version 6.7, which I used. So, is there some approach in call such bean properties in Hybris 6.7?

     <editorArea:editor-parameter>
            <editorArea:name>dateFormat</editorArea:name>
           <editorArea:value>{@myBean.getSomeMethod()}</editorArea:value>
     </editorArea:editor-parameter>
    
    
    

    KR, Nickolay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 29, 2016 at 09:19 AM

    Hi!

    Please take a look at com.hybris.cockpitng.core.util.impl.ListPropertyExtender

    You could use it by following snippet:

     <bean class="com.hybris.cockpitng.core.util.impl.ListPropertyExtender" init-method="extend" destroy-method="clean" lazy-init="false">
             <property name="parentBean" ref="fixedBeanResolver"/>
             <property name="propertyName" value="availableBeanNames" />
             <property name="additionalValues">
                 <list/>
             </property>
         </bean>
    
    

    And add your bean in list there. There is also a property "filtered", if you wish to avoid adding same value twice.

    Cheers, Jacek

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 12, 2017 at 08:57 AM

    Hi,

    Please try platformbackoffice.available.bean.names.for.spel local property which should contain a list of all beans that should be available via SpEL (so I would rather add some to following list rather then replace it: labelService,enumerationService,exceptionTranslationService).

    Cheers, Jacek

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 15, 2019 at 04:07 PM

    From Hybris 6.7 class BeanPropertyExtender is removed. But you can use extender functionality

    https://answers.sap.com/questions/12768385/defaulteditorarea-renderer.html

    <cng:property-extender ...>...</cng:property-extender>
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.