How do I pass an Asset Name (I selected) to a controller on a different page
-
14-04-2021 - |
문제
I created a custom Page which loads a list of Assets. I click on the Asset Name and now want to send the Asset name I clicked to my Controller so that I can do :
Asset myasset = SELECT name from Asset where name = [CLICKED ASSET NAME TEXT]
How do I pass that data to the controller.
Thank you
해결책
VisualForce:
<apex:repeat value="{!theAssets}" var="asset">
<apex:commandLink value="{!asset.Name}" action="{!someAction}">
<apex:param name="paramName" assignTo="{!assetName}" value="{!asset.Name}" />
</apex:commandLink>
</apex:repeat>
In the controller, make sure you define the property for the asset name:
public String AssetName { get; set; }
Elsewhere in the controller, you could have the statement:
Asset myasset = [SELECT name from Asset where name = :AssetName];
제휴하지 않습니다 StackOverflow