Yes... you can do with the help of @RemoteAction
VisualForce:
<apex:page controller="AccountRemoteActionController" readonly="true">
<script type="text/javascript">
function getAccountJS()
{
//get the values of input text and place into the variable.
var accountNameJS = document.getElementById('accName').value;
AccountRemoteActionController.getAccount( accountNameJS,
function(result, event)
{
alert('event.status==>'+event.status);
alert('event.type === '+event.type);
alert('event.message ==>'+event.message);
if (event.status)
{
// demonstrates how to get ID for HTML and Visualforce tags
document.getElementById("{!$Component.theBlock.thePageBlockSection.theFirstItem.accId}").innerHTML = result.Id;
document.getElementById("{!$Component.theBlock.thePageBlockSection.theSecondItem.accNam}").innerHTML = result.Name;
}
else if (event.type === 'exception')
{
document.getElementById("errors-js").innerHTML = event.message;
} else
{
document.getElementById("errors-js").innerHTML = 'No Records Found..';
}
}, {escape:true});
}
</script>
Account Name :<input id="accName" type="text" />
<button onclick="getAccountJS()">Get Account</button>
<div id="errors-js"> </div>
<apex:pageBlock id="theBlock">
<apex:pageBlockSection id="thePageBlockSection" columns="2">
<apex:pageBlockSectionItem id="theFirstItem">
<apex:outputText id="accId"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="theSecondItem" >
<apex:outputText id="accNam" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
ApexClass(@remoteAction):
global class AccountRemoteActionController{
public String accountName { get; set; }
public static Account account { get; set; }
//Default Constructor..
public AccountRemoteActionController() {
}
@RemoteAction
global static Account getAccount(String accountName) {
account = [select id, name, phone, type, numberofemployees from Account where name = :accountName ];
account.name = account.name+ 'ReadonlyUpdated';
update account;
return account;
}}
Output:
Let me know if you face any other issue.
Cheers!!!
Pradeep
"In read-only mode, a page may not execute any DML operations, but the limit on the number of records retrieved is relaxed from 50,000 to 1 million rows. It also increases the number of items in a collection that can be handled by iteration components, from 1,000 to 10,000. If not specified, this value defaults to false."