Message Boards

« Back to 2.- Usage ( From Xml file to CRUD Portlet)

RE: Search doesn't work in multi application

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hi,

I'm trying to dvlp a Skill Matrix in Liferay for my company using the XMLPortletFactory. Here is what I'm trying to do:

- 1 portlet used to add Master Technologies (Oracle, Microsoft, aso...)
- 1 portlet used to add Sub Technologies related to Master Technologies (for Oracle: RAC, Data Guard, Tunning, aso...)
- 1 portlet used to add all employees with their knowledge on this Sub Technologies (None, Theorical, Expert, aso...)

For that purpose, I've build the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<definition xmlns="https://www.xmlportletfactory.org/xml/xmlportletfactory"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://www.xmlportletfactory.org/xml/xmlportletfactory xmlportletfactory.xsd"
>
    <commonData>
        <client>skillMatrix</client>
        <projectName>skillMatrix</projectName>
        <version>1</version>
    </commonData>
    <applications>

        <application>
            <classDef>
                <name>techMaster</name>
                <title>Technology</title>
                <mode>
                    <add>true</add>
                    <delete>true</delete>
                    <modify>true</modify>
                    <browse>true</browse>
                </mode>
                <restrictBy>
                    <companyId>true</companyId>
                    <groupId>false</groupId>
                    <userId>false</userId>
                </restrictBy>
            </classDef>
            <fileDef>
                <name>techmaster</name>
                <fields>
                    <field>
                        <name>techmasterId</name>
                        <title>Id</title>
                        <type>
                            <long>
                                <length>5</length>
                                <signed>false</signed>
                                <nullable>false</nullable>
                                <order>true</order>
                            </long>
                        </type>
                        <showFieldInView>true</showFieldInView>
                        <required>true</required>
                    </field>
                    <field>
                        <name>techmasterName</name>
                        <title>Technology Name</title>
                        <type>
                            <varchar>
                                <length>50</length>
                                <order>true</order>
                                <unique>true</unique>
                            </varchar>
                        </type>
                        <showFieldInView>true</showFieldInView>
                        <required>true</required>
                    </field>
                </fields>
            </fileDef>
            <detailFiles>
                <detailFile>
                    <connectionFieldName>techmasterId</connectionFieldName>
                    <connectionTitle>TechMaster - TechDetails</connectionTitle>
                    <detailFileClassName>techDetails</detailFileClassName>
                </detailFile>
            </detailFiles>            
        </application>

        <application>
            <classDef>
                <name>techDetails</name>
                <title>Technology</title>
                <mode>
                    <add>true</add>
                    <delete>true</delete>
                    <modify>true</modify>
                    <browse>true</browse>
                </mode>
                <restrictBy>
                    <companyId>true</companyId>
                    <groupId>false</groupId>
                    <userId>false</userId>
                </restrictBy>
            </classDef>
            <fileDef>
                <name>techdetails</name>
                <fields>
                    <field>
                        <name>techdetailsId</name>
                        <title>Id</title>
                        <type>
                            <long>
                                <length>5</length>
                                <signed>false</signed>
                                <nullable>false</nullable>
                                <order>true</order>
                            </long>
                        </type>
                        <showFieldInView>true</showFieldInView>
                        <required>true</required>
                    </field>
                    <field>
                        <name>techmasterId</name>
                        <title>Tech Master Id</title>
                        <type>
                            <long>
                                <length>5</length>
                                <signed>false</signed>
                                <nullable>false</nullable>
                                <order>true</order>
                            </long>
                        </type>
                        <showFieldInView>false</showFieldInView>
                        <required>true</required>
                    </field>
                    <field>
                        <name>techdetailsName</name>
                        <title>Technology Name</title>
                        <type>
                            <varchar>
                                <length>50</length>
                                <order>true</order>
                                <unique>true</unique>
                            </varchar>
                        </type>
                        <showFieldInView>true</showFieldInView>
                        <required>true</required>
                    </field>
                </fields>
            </fileDef>
            <detailFiles>
                <detailFile>
                    <connectionFieldName>techdetailsId</connectionFieldName>
                    <connectionTitle>TechDetails - UsersSkills</connectionTitle>
                    <detailFileClassName>usersSkills</detailFileClassName>
                </detailFile>
            </detailFiles>            
        </application>
        
        <application>
            <classDef>
                <name>usersSkills</name>
                <title>Consultant</title>
                <mode>
                    <add>true</add>
                    <delete>true</delete>
                    <modify>true</modify>
                    <browse>true</browse>
                </mode>
                <restrictBy>
                    <companyId>true</companyId>
                    <groupId>false</groupId>
                    <userId>false</userId>
                </restrictBy>
            </classDef>
            <fileDef>
                <name>usersskills</name>
                <fields>
                    <field>
                        <name>consultantId</name>
                        <title>Id</title>
                        <type>
                            <long>
                                <length>5</length>
                                <signed>false</signed>
                                <nullable>false</nullable>
                                <order>true</order>
                            </long>
                        </type>
                        <showFieldInView>true</showFieldInView>
                        <required>true</required>
                    </field>
                    <field>
                        <name>techdetailsId</name>
                        <title>Tech Details Id</title>
                        <type>
                            <long>
                                <length>5</length>
                                <signed>false</signed>
                                <nullable>false</nullable>
                                <order>true</order>
                            </long>
                        </type>
                        <showFieldInView>false</showFieldInView>
                        <required>true</required>
                    </field>
                    <field>
                        <name>consultantName</name>
                        <title>Consultant Name</title>
                        <type>
                            <varchar>
                                <length>50</length>
                                <order>true</order>
                                <filter>true</filter>
                            </varchar>
                        </type>
                        <showFieldInView>true</showFieldInView>
                        <required>true</required>
                    </field>
                    <field>
                        <name>consultantLevel</name>
                        <title>Level</title>
                        <type>
                            <varchar>
                                <length>20</length>
                                <order>true</order>
                                <filter>true</filter>
                            </varchar>
                        </type>
                        <showFieldInView>true</showFieldInView>
                        <required>true</required>
                    </field>
                </fields>
            </fileDef>        
        </application>

    </applications>
</definition>

I've build the portlet and I'm able to add a Master Technology, then a Sub related to this Master and finally I can add employees. The problem is that the search just don't work. In fact if I try to add <filter>true</filter> on the "techmasterName", It will works (this is the "Master" application). That means that I can search for "Oracle" and I will only see the corresponding line. But If I try to add <filter>true</filter> on a properties that is not in the "Master" application (One of the Details applications), the searchbox appears on the UI but the search doesn't works.

With the two employees "Morgan" and "David", If I do a search using "Morgan" then the search filter doesn't do anything because I can still see the two lines.

Anyone know what I should do to fix this?

Thanks for your help. Regards,
Morgan

RE: Search doesn't work in multi application
Answer
5/6/14 8:13 AM as a reply to Morgan.
Hi Morgan,

as you said, for IPC multi-portlet webapp, the "slave" records are fixed. In fact, the Master Id is stored in session and only the slave records related to that master key will be fetched.

We removed the search part intentionally, as we didn't see it made sense.

Said that, if you want to add then, in your SubTechnologiesPortlet.java, showViewDefault, you sohuld add search code. You can create another portlet using the same XML, and enable <filter>.

Then you can copy that search code in showViewDefault and paste in your SubTechnologiesPortlet.java.

RE: Search doesn't work in multi application
Answer
10/22/16 9:46 PM as a reply to Juan G..
I know this is quite a bit old thread, but if anyone is interested, iIn addition to what Juan mentioned, there are better ways to do this:
I did it as follows:
Made the search code part of the .vm template, generating the portlet java file.
    I updated the Portlet_XXXXXXPortlet_java.vm with the code, necessary to do the proper filtering. It was actually quite easy. If you are interested in the actual code modification, let me know.
Other ways include modifying the schema and/or using conditional schema elements to enable/disable <filter> processing only if a <mdfilter>true</mdilter> (as in master-detail filter new tag) is present...
Again, those are just ideas...