Wednesday, May 2, 2012

How to hide an required attribute in self-care portlet?

Our customer wants to hide all field except password field in self-care portlet. They do not use self-registration, but they only want to be able to change a user password from self-care portlet.

The solution is quite easy - you can disable fields in config mode of self-care portlet directly.
But how to disable/hide required fields from the portlet? They are inactive - so administrator can not disable them.


First you have to remove required attributes from store.puma_default.user.add.required.attributes properties.

  1.  Log in to the IBM WebSphere® Integrated Solutions Console (ISC). 
  2. Go to Resources >> Resource Environment >> Resource Environment Providers
  3. Click on the link for WP PumaStoreService. Under "Additional properties" click on "custom properties"
  4. Click on the link for "store.puma_default.user.add.required.attributes
  5. Delete all from value field
  6. Save and restart portal :( 
  7. Then go again in to config mode and disable all remaining attributes.
Actualy some fields are disabled because they are required fields in PUMA (user management), and cannot be removed. To hide them, it is easiest way to edit JSP which render self-care form. I added only display: none css for sn attribute part of form.

Edit file
/opt/IBM/WebSphere/wp_profile/installedApps/Node01/PA_Selfcare_Port_App.ear/selfcare.war/WEB-INF/jsp/UserInformationFormInclude.jspf


    <tr style="display:none;">
        <td align="<%=bidiAlignRight%>">
            <% if (requiredUserAttributes.contains(SelfcareConstants.LAST_NAME_FIELD_ID)) { %> * <% } %>
        </td>
        <td align="<%=bidiAlignLeft%>" class="wpsEditText">
            <label for="<%= SelfcareConstants.LAST_NAME_FIELD_ID %>">
                <fmt:message key="selfcare.label.last_name"/>
              <% if (isRequiredAttr) { %><span style="display:none"><fmt:message key="selfcare.label.required_attr"/></span> <% } %>
            </label>
        </td>
    </tr>
    <tr style="display:none;">
        <td>&nbsp;</td>
        <td>
            <input <%=bidiDirAttr%>
                   class="wpsEditField" 
                   type="text" 
                   id="<%= SelfcareConstants.LAST_NAME_FIELD_ID %>" 
                   name="<%=SelfcareConstants.USER_ATTRIBUTE_PREFIX%><%= SelfcareConstants.LAST_NAME_FIELD_ID %>" 
                   value='<% escapeXmlWriter.write(sn);%>'
                   onkeyup="javascript:updateDisplayName();return;" >
        </td>
        <td class="wpsFieldErrorText">
        </td>
    </tr>
Delete temp folder

/opt/IBM/WebSphere/wp_profile/temp/Node01/WebSphere_Portal/PA_Selfcare_Port_App

 and reload page with self-care portlet

No comments:

Post a Comment