Breakpoints inside the button click even is not getting hit while debugging apex code with VS Code - salesforce

I am using VS code. Trying to render a button with a button click event. The code is as below
<apex:page controller="OnAuthorizeController">
<apex:form>
<apex:commandButton value="Get token" action="{!getToken}" />
</apex:form>
</apex:page>
public with sharing class OnAuthorizeController {
public void getToken(){
string str = 'dummy code'; // break point here is never triggered
string str2 ='dummy code2';
}
}
I am trying to debug the codes inside a button-click event. Generated Apex debug logs and tried to debug but the breakpoints are only getting hit in the page load event. Once the page is rendered, it is impossible to debug the code inside the button click event. Trying to debug as described in this 4 mins video https://www.youtube.com/watch?v=dNBsYLfI1nk
I tried all the possible googling to debug the apex code with VS code. I expect to debug the code inside a button click event in apex page

Related

Visualforce Select checkbox empty in controller

I have a string list in my controller
public List<String> m_lstChosenCloneOptions{get;set;}
with the following code in the page
<apex:selectCheckboxes value="{!m_lstChosenCloneItems}" layout="pageDirection">
<apex:selectOptions value="{!CloneOptions}" />
</apex:selectCheckboxes>
There are 3 options and I default all of the to checked by putting the keys into m_lstChosenCloneItems. It works because the page displays with all the items checked. I also have a button that when clicked starts a cloning process. However, the first line in the controller is a System.Debug(m_lstChosenCloneItems); and it displays as empty. I'm not sure how at the final line of the constructor the list is filled with the options but just clicking the button right after the page loads, the list is empty.
Update: I added the type above it is a public list.
Here is the button and controller:
<apex:commandButton value="Clone Project" action="{!cloneProject}" rerender="messagepanel"/>
public void cloneProject()
{
System.Debug(m_lstChosenCloneOptions);
}
FYI I was able to "fix" this by adding a javascript that grabs the checkboxes and passes in their values to an apex:param. But I'm still curious why the binding with the list isn't working. Maybe the function being void is the issue?

Make UI uneditable when we are moving from one page to another

I am trying to do userLogin through a webservice. The project is using Bootstrap for css and angular in the backend.
I am having a login Screen with a hidden div that is shoown when user click login button.Its a animated login icon.
Everything is working fine.I just want to make the background that is whole page including the userId, password uneditable as well as signin button unclickable.
When you hit the login button you can make the input(s) and button(s) disabled to make sure they remain unchanged.
When you get a result from your REST call you can re-enable them all.
You probably already have a variable $scope.loginIn on your controller scope since you are showing an animated login icon while login. If you don't, add it to your login function, something like :
$scope.login = function(...) {
$scope.loginIn = true;
loginService.login(...).finally() {
$scope.loginIn = false;
}
}
then just use it on your input and buttons to disable them :
<div class="login">
<input enable="!loginIn">...</input>
<button enable="!loginIn">...</button>
</div>
(That might be off the context, if you give me some code I could probably be more accurate in my answer)

Oracle ADF: java.lang.IllegalArgumentException when pressing Printable page behaviour 12c

Hello am developing a web application using Oracle ADF and jdev12c. I have a page like below.
The above page is created using a template. That contains three parts. First part is image, second part is deck with more than one panel group layout (Here deck child value is decided using a value from managed bean of scope session.)and third part is actual content facet in this I have dropped a task-flow(bouded) as a region contain .jsff pages.
My problem is every thing is working fine. af:showPrintableBehavior is not working. When I click on the Printable view button am getting the following exception. After the following exception nothing is working in my application. (If I click on any commndLink it is opening in another tab and repeatedly trying to generate the page content for example the table but not displaying the content)
exception
java.lang.IllegalArgumentException
org.apache.myfaces.trinidad.model.RowKeySetTreeImpl.setCollectionModel(RowKeySetTreeImpl.java:315)
org.apache.myfaces.trinidad.component.UIXListView$RowKeyFacesBeanWrapper.getProperty(UIXListView.java:300)
org.apache.myfaces.trinidad.component.FacesBeanWrapper.getProperty(FacesBeanWrapper.java:61)
oracle.adf.view.rich.component.rich.data.RichListView$ListViewBeanWrapper.getProperty(RichListView.java:178)
org.apache.myfaces.trinidad.component.UIXComponentBase.getProperty(UIXComponentBase.java:1912)
org.apache.myfaces.trinidad.component.UIXListView.getSelectedRowKeys(UIXListView.java:451)
org.apache.myfaces.trinidad.component.UIXListView.postCreateCollectionModel(UIXListView.java:157)
org.apache.myfaces.trinidad.component.UIXCollection.getCollectionModel(UIXCollection.java:1671)
org.apache.myfaces.trinidad.component.UIXCollection.getCollectionModel(UIXCollection.java:1255)
org.apache.myfaces.trinidad.component.UIXCollection.getRowKey(UIXCollection.java:493)
oracle.adf.view.rich.component.rich.data.RichListView.visitChildren(RichListView.java:103)
org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:774)
org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:631)
org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:405)
org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:504)
org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:482)
org.apache.myfaces.trinidad.component.UIXComponent.visitChildren(UIXComponent.java:774)
org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:631)
org.apache.myfaces.trinidad.component.UIXComponent.visitTree(UIXComponent.java:405)
org.apache.myfaces.trinidad.component.UIXComponent.visitAllChildren(UIXComponent.java:504)
This is not working in only this page. I have tested this in one empty page that is created without using this template. In that empty page I have created this table and tried with af:showPrintableBehavior and here this behaviour is working fine.
Please help me. How to remove the above exception. Export to excel is working fine.
Thanks in advance.
Try using a clientListener inside the button that prints the page, then stop the event from propagating further:
<af:resource type="javascript">
/**
* Shows a popup from an "action" type event.
* #param {AdfActionEvent} actionEvent the event being handled
*/
function stopEventFromPropagating(actionEvent)
{
actionEvent.cancel();
}
</af:resource>
<af:commandButton text="Click Me">
<af:clientListener type="action" method="stopEventFromPropagating"/>
</af:commandButton>

Error when clicking Add-button in CRUD

When a form or an add-button returns to a page, it throws an error or shows wrong output on the page, if there is js or other kinds of output on the page. Here is an example:
$tabs->addTab('Skoler')->add('CRUD')->setModel('School');
$crud=$tabs->addTab('Elever')->add('CRUD');
$crud->setModel($student);
if($crud->grid){
$crud->grid->addButton('addStudents')->set('Importer elever')->js('click',$this->js()->univ()
->dialogURL('Importer elever',$this->api->url('importusers&usertype=student'))
->execute());;
$crud->grid->js(true)->addClass('reloadstudent');
$crud->grid->js('.reloadstudent')->reload();
}
When clicking on "Add School" This outputs
$('#barometeradmin_mgr').univ().dialogURL('Importer elever','/redskab/barometer/admin/?page=importusers\x26usertype=student\x26barometeradmin_mgr_tabs_view_htmlelement_crud_virtualpage=add')
in the dialogurl created by the button.
Is there a way to check if the page is loaded for the second time (that is, by the button).
Thanks!
Jeppe
I think all you need to do is leave out the '->execute()'?

Visualforce passing static resource URL to Apex

I am trying to pass a static resource URL, via the apex:param tag. The code I have so far is:
VisualForce:
<apex:selectList value="{!SelectedFamily}" onchange="renderGallery();" size="1" label="Product Family">
<apex:actionFunction name="renderGallery" rerender="gallery" oncomplete="renderScripts();">
<apex:param value="{!URLFOR($Resource.NoImage)}" assignTo="{!noImage}"/>
<apex:param value="{!URLFOR($Resource.NoImageThumb)}" assignTo="{!noImageThumb}"/>
</apex:actionFunction>
<apex:actionFunction name="renderScripts" rerender="scriptPanel">
</apex:actionFunction>
<apex:selectOptions value="{!Family}" />
</apex:selectList>
Controller:
public string noImage{ get; set; };
public string noImageThumb { get; set; }
My understanding of apex:param was that I would now be able to call the controller variables after the re-render had occurred and they would be populated with the static resource URL. But unfortunately I keep getting null.
Anyone have any idea why it isn't working?
It works if you provide names for your params --- Visualforce won't process params in this context unless they're named.
<apex:actionFunction name="renderGallery" rerender="gallery" oncomplete="renderScripts();">
<apex:param name="noImg" value="{!URLFOR($Resource.NoImage)}" assignTo="{!noImage}"/>
<apex:param name="noImgUrl" value="{!URLFOR($Resource.NoImageThumb)}" assignTo="{!noImageThumb}"/>
</apex:actionFunction>
If this doesn't work for you right away, please post the rest of your Visualforce code so that we can see where "gallery" and "scriptPanel" are in relation to your apex form tag --- getting rerender to work correctly is notoriously tricky, and entirely dependent on the hierarchical position of the DOM elements getting rerendered. To guarantee that gallery and scriptPanel successfully rerender, put them in separate outputPanels outside the apex form tag, like this:
<apex:outputPanel id="scriptPanel">
Selected Family: {!SelectedFamily}<br/>
</apex:outputPanel><br/><br/>
<apex:outputPanel id="gallery">
No Image: {!noImage}<br/>
No Image Thumb: {!noImageThumb}<br/>
</apex:outputPanel><br/><br/>
#MatthewKeefe, there's absolutely no reason why {!URLFOR()} can't be used as an extension variable --- it compiles to text (e.g. '/resource/123718923'), so Jim's solution here is actually pretty interesting, as it saves him from having to do a SOQL query on the StaticResource object in his controller.
{!URLFOR($Resource.NoImage)} is not meant to be used as a controller/extension variable. It is a direct reference to the static resource (no controller/extension required).
I would recommend you use output panels with a rendered property bound to an Apex variable that is controlled by the action function. That way you could show or hide each version of the image by showing or hiding the output panel.
Alternatively, you may want to look into using JavaScript Remoting for something like this.

Resources