function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nelloCnelloC 

Lookup button in blocksectionitem

I would like to place a lookup button (a commandlink with an icon) to the right of an inputtext field. The field and it's label are within a pageBlockSectionItem. When I attempt to place link to the right of the inputtext field I obviously get the error: <apex:pageBlockSectionItem> may have no more than two child components.

Is there any way of placing a link to the right of this field or must I abandon the pageblocksection?

 

The field in question...

 

<apex:pageBlockSectionItem> <apex:commandLink value="To" id="to_contact_link" immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"/> <apex:inputText value="{!ToContactName}" id="to_contact"></apex:inputText> </apex:pageBlockSectionItem>

 Would like to do this...

 

<apex:pageBlockSectionItem> <apex:commandLink value="To" id="to_contact_link" immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"/> <apex:inputText value="{!ToContactName}" id="to_contact"></apex:inputText> <apex:commandLink immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"> <apex:image value="{!$Resource.SearchIconA}"/> </apex:commandLink> </apex:pageBlockSectionItem> 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
jwetzlerjwetzler

you can always use apex: outputPanel to surround a group of elements.  All it does is output a span tag.

 

wrap your inputText and commandLink in an outputPanel, then you only have two child components of pageBlockSectionItem.

All Answers

Ajay111Ajay111

 

<apex:pageBlockSection columns="2">
<apex:pageBlockSectionItem>
<apex:commandLink value="To" id="to_contact_link" immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"/>
<apex:inputText value="{!ToContactName}" id="to_contact"></apex:inputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:commandLink immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form">
<apex:image value="{!$Resource.SearchIconA}"/>
</apex:commandLink>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

 use This code.

nelloCnelloC

Ajay

 

Thanks for your reply. Unfortunately this field is just one of a whole bunch of fields on my form and if I make the pageblocksection 2 columns then all fields on the form get squashed to the left and the search icon is still not placed next to the inputtext as I'd like it to be. I'm really just trying to preserve the standard salesforce format if possible but it's not looking hopeful at the moment...

 

I did try this...

<apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem> <apex:commandLink value="To" id="to_contact_link" immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"/> <apex:inputText value="{!ToContactName}" id="to_contact"> <apex:commandLink immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"> <apex:image value="{!$Resource.SearchIconA}"/> </apex:commandLink> </apex:inputText> </apex:pageBlockSectionItem> </apex:pageBlockSection>

 Which it didn't object to but unfortunately the icon was placed before the inputtext and not after... Don't suppose anyone has any other ideas?

 

 

jwetzlerjwetzler

you can always use apex: outputPanel to surround a group of elements.  All it does is output a span tag.

 

wrap your inputText and commandLink in an outputPanel, then you only have two child components of pageBlockSectionItem.

This was selected as the best answer
nelloCnelloC

Jill you're wonderful!! Thanks for that, I should have seen that myself but just hadn't got round to using the outputpanel yet...

 

Regards

Neal