Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  update custom control when user moves to Next record

    Posted Wed February 09, 2022 06:21 PM

    I have posted this question elsewhere. If you are seeing it "again", please accept my apology.

    I have created a simple "label" custom control based on Viet Tran's Maximo custom control (Part IV) – Create a chart control blog post. All my control has to do is put "Hello <valueOfDataattribute>!" in the HTML, like this:

    As shown above, it works when you load a record from the List. However, if you load a record by using the Previous or Next buttons, it does not update.


    Here is properties/registry-extensions/mycontrol-registry-extension.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <control-registry basedir="webclient/controls" package="psdi.webclient.controls"
            xsi:noNamespaceSchemaLocation="../control-registry.xsd"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <control-descriptor name="mycontrol">
            <property-list>
                <property name="id">
                    <flag name="final" />
                </property>
                <property name="datasrc">
                    <flag name="nonconditional" />
                    <flag name="global" />
                </property>
                <property name="dataattribute">
                    <flag name="final"/>
                </property>
            </property-list>
            <component-list>
                <components id="co" layout="horizontal">
                    <mylabelcomponent id="co1"/>
                </components>
            </component-list>
            <containers>
                <container name="section" />
            </containers>
        </control-descriptor>
    </control-registry>

     

    Here is properties/registry-extensions/mylabel-registry-extension.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <component-registry basedir="webclient/components"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../component-registry.xsd">
        <component-descriptor name="mylabelcomponent" instance-class="${package}.controller.BoundComponentInstance">
            <property-list>
                <property name="jsp-filename">
                    <default-value>mylabel</default-value>
                </property>
                <property name="id">
                    <flag name="final" />
                </property>
            </property-list>
        </component-descriptor>
    </component-registry>

     

    Here is maximouiweb/webmodule/webclient/components/mylabel.jsp:

    <%@include file="../common/componentheader.jsp" %>
    <%
        String text = control.getPage().getDataBean().getMbo().getString(control.getProperty("dataattribute"));
    %> 
    <div>Hello <%=text%>!</div>
    <%@include file="../common/componentfooter.jsp" %>

     

    Note that I have tried this in mylabel.jsp but the result did not change.

    <div>Hello <%=control.resolveParams("{"+control.getProperty("dataattribute")+"}")%>!</div> 


    To use my control, I put this in the XML for my application (precautn / Precautions) by export / import:

    <mycontrol id="mycontrol1" dataattribute="precautionid"/>

     

    What have I missed?



    ------------------------------
    Blessings,
    Jason Uppenborn
    Sr. Technical Maximo Consultant
    Cohesive Ontracks
    ------------------------------

    #Maximo
    #AssetandFacilitiesManagement


  • 2.  RE: update custom control when user moves to Next record

    Posted Thu February 10, 2022 01:41 AM
    Edited by System Admin Wed March 22, 2023 11:45 AM
    Hi Jason,

    You've to create a Custom Control Java Class overwriting the render() Method:

    /**
    *
    */
    public int render() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    setChangedFlag();
    return super.render();
    }

    Don't forget to reference your class in the registry-extensions xml.
    cheers
    Johann

    ------------------------------
    Johann Rumpl
    Maximo Senior Consultant
    EAM Swiss GmbH
    Gais
    Switzerland
    ------------------------------



  • 3.  RE: update custom control when user moves to Next record

    Posted Thu February 10, 2022 06:19 PM
    That doesn't seem to have helped.

    Source for maximouiweb/webmodule/WEB-INF/classes/demo/webclient/system/controller/DemoBoundComponentInstance.class:
    package demo.webclient.system.controller;
    
    import java.lang.reflect.InvocationTargetException;
    
    import psdi.webclient.system.controller.BoundComponentInstance;
    
    public class DemoBoundComponentInstance extends BoundComponentInstance {
    
    	public DemoBoundComponentInstance() {
    		super();
    	}
    
    	@Override
    	public int render() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    		setChangedFlag();
    		return super.render();
    	}
    }​


    changed line in mylabel-registry-extension.xml
    <component-descriptor name="mylabelcomponent" instance-class="demo.webclient.system.controller.DemoBoundComponentInstance">​


    ------------------------------
    Blessings,
    Jason Uppenborn
    Sr. Technical Maximo Consultant
    Cohesive Ontracks
    ------------------------------



  • 4.  RE: update custom control when user moves to Next record

    Posted Fri February 11, 2022 09:49 AM
    Hi Jason,

    On our end it worked reliable after overwriting the CONTROL not the COMPONENT class. These are two different things and honestly said I can't explain the difference. In one of our developements the control registry looks like that:

    <control-descriptor name="eam_dynamiccalendar" instance-class="ch.eam.webclient.controls.EAMDynamicCalendarControl">
    <property-list>
    <property name="display">

    The class mentioned extends psdi.webclient.system.controller.ControlInstance

    Are you able to debug classes? Is/are the method(s) executed if you press the next/previous buttons?

    Cheers
    Johann

    ------------------------------
    Johann Rumpl
    Maximo Senior Consultant
    EAM Swiss GmbH
    Gais
    Switzerland
    ------------------------------



  • 5.  RE: update custom control when user moves to Next record

    Posted Mon February 14, 2022 10:19 AM
    I moved the customization from the component to the control, but that didn't help.

    A control is a collection of components. For example, a Textbox control has a label component and a textbox component.

    Unfortunately, I'm not able to debug.

    ------------------------------
    Blessings,
    Jason Uppenborn
    Sr. Technical Maximo Consultant
    Cohesive Ontracks
    ------------------------------



  • 6.  RE: update custom control when user moves to Next record

    Posted Mon February 21, 2022 03:42 PM

    I suggest changing your control registry entry to:

      <control-descriptor name="mycontrol">

        <property-list>

            <property name="id">

                <flag name="final" />

            </property>

            <property name="datasrc">

                <flag name="nonconditional" />

                <flag name="global" />

            </property>

            <property name="dataattribute">

                <flag name="final"/>

            </property>

        </property-list>

        <component-list>

            <components id="co" layout="horizontal">

                <mylabelcomponent id="co1" dataattribute="@{dataattribute}" />

            </components>

        </component-list>

        <containers>

            <container name="section" />

        </containers>

      </control-descriptor>

     

    Component registry entry to:

      <component-descriptor name="mylabelcomponent" instance-class="${package}.controller.BoundComponentInstance">

        <property-list>

            <property name="jsp-filename">

                <default-value>mylabel</default-value>

            </property>

            <property name="id">

                <flag name="final" />

            </property>

            <property name="dataattribute" />

            <property name="defaultrender">

              <default-value>true</default-value>

            </property>

        </property-list>

      </component-descriptor>

     

    And your component jsp to:

    <%@include file="../common/componentheader.jsp" %>

    <div id="<%=id%>">Hello <%=boundComponent.getString()%>!</div>

    <%@include file="../common/componentfooter.jsp" %>



    ------------------------------
    Brian Ragusa
    Senior Software Engineer
    IBM
    ------------------------------



  • 7.  RE: update custom control when user moves to Next record

    Posted Tue February 22, 2022 11:16 AM
    Thank you so much, Brian! That works great!

    ------------------------------
    Blessings,
    Jason Uppenborn
    Sr. Technical Maximo Consultant
    Cohesive Ontracks
    ------------------------------