• Lelouch
  • NEWBIE
  • 45 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 0
    Replies
Thank you for your assistance.

I would like to pass parameters from a Visualforce page to the Visualforce and controller classes of the administration package.
URL parameters can be passed, but not when POSTing.
In the development environment, it can be passed, but not at the installation site.

What is the cause?

■Code
・In the original Visualforce page,
<form id="SubmitForm" action="/apex/sapmplePage" method="post" style="display:none">
        <input type="hidden" id="ids" name="ids"/>
        <input type="hidden" id="obj" name="obj"/>
</form>


Parameters are set by Javascript window.onload before submit.

・The controller on the original Visualforce page is Account
・he controller of the management package is customCon.
String id = ApexPages.currentPage().getParameters().get('ids');


Can someone please help me?

Thank you for your assistance.

I have created a management package and would like to be able to change the value of the custom label at the installation site.

How can I implement this?
Currently it is not possible to change the value.

If not, do I need to use custom metadata, custom settings, etc.?

Thank you for your help.

I would like to use Javascript variables for rendered and style attributes in Visualforce.

1.
How should I describe the Javascript variables in Visualforce?

2.
Can I rewrite attributes of Visualforce tags?
If you can, please let me know.
初心者です。
VisualforceとJavascriptでの値の参照方法について質問させてください。

Javascriptの変数の値(true,false)でVisualforceのapex:formの表示非表示を行いたいです。
renderedで制御したいのですが、Javascriptの変数の値はどのようにして記載すればよろしいのでしょうか?
{!XXX}だとコントローラを探しに行ってしまいます。

もし上記が不可能な場合、Apexにパラメータを渡して、Apexで処理をしてbooleanを返してもらう手段を取ろうと思っているのですが、Apexへのパラメータの渡し方と受け取り方がわかりません。

よろしくお願いいたします。
ありがとう。

お世話になっております。

Visualforceのoutputfieldを順番に選択(MAX2つ)したら、Apexコントローラの変数へその値を受け渡ししたいです。
その後、画面で2つ選択された場合(1つだと非表示のまま)のみ、Visualforceページの下部のその値を表示させたいです。

画面の流れのイメージ)
・VIEW
outputFieldを2つクリック

・Controller
クリックされた2つの値を変数に格納

・VIEW
2つ選択されている場合のみ、選択された値(コントローラの変数の値)を下部にパネルタグか何かで囲って表示
※画面で1つしか選択されていなければそのエリアは非表示のまま

■Visualforce
・・・
<apex:outputPanel >
    <p title="{!sobj[f]}">
        <apex:outputField value="{!sobj[f]}"/>
    </p>
</apex:outputPanel>

・・・

<apex:actionFunction name="showCompare" action="{!toDetailPage}" reRender="pageId">      
    <apex:param name="values" value=""/>
</apex:actionFunction>  

・・・

■Javascript
・・・
var value = tag.querySelector('p').getAttribute('title');
values.push(value);
・・・

■Apex
text1 = 
text2 =


簡単なサンプルで構いませんので、Apexで選択した値2つ受け取る方法を教えていただけたら幸いです。
非常に非常に困っています。
ありがとう。
ラッパー
質問失礼します。

ラッパークラスを作成し、選択したレコードをクラス内の変数に保ちたいです。

どのように実装したらよろしいでしょうか?
イメージとしては、ボタンを作成しボタン押下したら、変数に保持しデバッグ出力したいです。

Visualforce
<apex:page controller="CheckboxTableViewController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="1">
                <apex:pageBlockTable value="{!wrappers}" var="item">
                    <apex:column style="width: 20px;">
                        <apex:inputCheckbox value="{!item.isChecked}" />
                    </apex:column>
                    <apex:column headerValue="Name">
                        <apex:outputText value="{!item.name}" />
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

コントローラ
public with sharing class CheckboxTableViewController {
    
    public List<CheckboxTableViewWrapper> wrappers {get; set;}
    
    public CheckboxTableViewController() {
        this.wrappers = getWrappers();
    }
    
    private List<CheckboxTableViewWrapper> getWrappers() {
        
        List<CheckboxTableViewWrapper> lists = new List<CheckboxTableViewWrapper>();
        
        Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
        List<Schema.PicklistEntry> pickListEntry = fieldResult.getPicklistValues();
        
        for (Schema.PicklistEntry pick: pickListEntry) {
            lists.add(new CheckboxTableViewWrapper(pick.getLabel()));
        }
        
        return lists;
    }
}

ラッパークラス
public with sharing class CheckboxTableViewWrapper {
    
    public Boolean isChecked {get; set;}
    public String name {get; set;}
    
    public CheckboxTableViewWrapper() {
        this.isChecked = false;
        this.name = '';
    }
    
    public CheckboxTableViewWrapper(String prmName) {
        this.isChecked = false;
        this.name = prmName;
    }
}


どなたかお力化していただけたら幸いです。
よろしくお願いいたします。​​​​​​​
  • September 25, 2023
  • Like
  • 0
Salesforce AppExchangeにアプリケーションを載せたいです。
色々なサイトを見ましたが、、、
リンクが切れていたり、情報が散らばっていて手順がわかりません。

手順とリンクを教えていただけないでしょうか?

困っているのでよろしくお願いいたします。
  • September 05, 2023
  • Like
  • 0
質問失礼します。

二つのテキストを比較し、差分を表現する画面です。
以下のコードの内容を教えてください。
他人のコードなのですが、私は初心者なので、どうしても理解できない箇所があります。

Question(1)
HTMLの"td.d1"や"td.d1 em.c1"などの記述がありますが、どこにも定義されておりませんが、どこを指している(何を意味している)のでしょうか?

Question(2)
Javascriptで、function diffxが何を行っているのかが分かりません。
一行ずつ解読しているのですが、どなたか一行ずつ解説を教えていただけませんでしょうか?

悩んで分からないので、助けていただければと思います。
初心者の私には難しいです。
よろしくお願いいたします。
-------

↓コード

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>HIKAKU</title>
<style type="text/css">
    body {
        background-color: #eeeeee; 
        color: #000000; 
        margin: 2; 
        padding: 2;
        font-family: Helvetica;
    }
    div {
        background-color: #dddddd;
        border: 1px solid #ff5555; 
    }

    table{
        width: 100%;
        border-collapse: collapse;
    }
    tr{
        width: 98%;
    }
    textarea {
        width: 98%;
        height: 200px;
        border: 2px solid #ffcc77; 
    }
    td {
        width: 10%;
        background-color: #ffffff;
        border-right: 1px dotted #555555; 
        border-bottom: 1px dotted #555555; 
        color: #000000;
        font-size: 12px;
        padding: 2px; 
        text-decoration: none;
        font-style: normal;
        word-break: break-all;
        vertical-align: top;
        vertical-align: baseline;
    }
    td.d1 {
        background-color: #ffffff;
        color: #000000;
        text-decoration: none;
        font-style: normal;
    }
    td.d2 {
        background-color: #ffffff;
        color: #000000;
        text-decoration: none;
        font-style: normal;
    }
    td.d1 em.c1 {
        background-color: #FF0000;
        display: none;/**/
    }
    td.d1 em.c2 {
        background-color: #88ff88;
    }
    td.d2 em.c1 {
        background-color: #8888ff;
    }
    td.d2 em.c2 {
        background-color: #ffff00;
        display: none;/**/
    }
    em.c1 {
        text-decoration: none;
        font-style: normal;
        vertical-align: baseline;
    }
    em.c2 {
        text-decoration: none;
        font-style: normal;
        vertical-align: baseline;
    }
</style>
<script type="text/javascript">
var fp = new Array();
var A = new Array();
var B = new Array();
var N;
var M;
var mC = new Array();

function init(){
        document.getElementById('ss1').value = sample_txt[0].t;
        document.getElementById('ss2').value = sample_txt[1].t;
}

function hikaku(){
            mC = new Array();
            s1 = document.getElementById('ss1').value;
            s2 = document.getElementById('ss2').value;
            diffx(s1, s2);
            var qa,qb;
            if(s1.length<=s2.length){
              qa = 1;
              qb = 2;
            }else{
              qa = 2;
              qb = 1;
            }
            var aa = mC.join("").split("\n");
            var ht = "";
            document.getElementById('sat1').innerHTML = "";
            for(var i = 0, len = aa.length; i < len; ++i){
                ht = ht + "<tr><td class=\"d"+qa+"\">" + aa[i] + "</td><td class=\"d"+qb+"\">" + aa[i] + "</td></tr>";
            }
            document.getElementById('sat1').innerHTML = "<table>" + ht + "</table>";
            ht = "";
}

function diffx(c1r, c2r){
  var A = c1r.split('');
  var B = c2r.split('');
  var M = A.length;
  var N = B.length;

  var exchanged = false;

  if(N > M){
    exchanged = true;
    var t;
    t = A;
    A = B;
    B = t;
    t = M;
    M = N;
    N = t;
  }

  var offset = N;
  var delta = M - N;
  var size = M + N + 1;
  for(var i = 0, fp = []; i < size; ++i){
    fp[i] = {
      y    : null,
      tree : null
    }
  }
  var snake = function(k){
    if((k < -N) || (M < k)){
      return;
    } else {
      var current = fp[k+offset];
      if(k === -N){
        var down  = fp[k+1+offset];
        current.y = down.y+1;
        current.tree = {
          type : '+',
          prev : down.tree
        }
      } else if(k === M){
        var slide = fp[k-1+offset];
        current.y = slide.y;
        current.tree = {
          type : '-',
          prev : slide.tree
        }
      } else {
        var slide = fp[k-1+offset];
        var down  = fp[k+1+offset];
        if(slide.y === null && down.y === null){
          current.y = 0;
        } else if(down.y === null || slide.y === null){
          if(down.y === null){
            current.y = slide.y;
            current.tree = {
              type : '-',
              prev : slide.tree
            }
          } else {
            current.y = down.y+1;
            current.tree = {
              type : '+',
              prev : down.tree
            }
          }
        } else {
          if(slide.y > (down.y+1)){
            current.y = slide.y;
            current.tree = {
              type : '-',
              prev : slide.tree
            }
          } else {
            current.y = down.y+1;
            current.tree = {
              type : '+',
              prev : down.tree
            }
          }
        }
      }
      var y = current.y;
      var x = y + k;
      while(x < M && y < N && A[x] === B[y]){
        current.tree = {
          type : '|',
          prev : current.tree
        }
        x++;
        y++;
      }
      current.y = y;
    }
  }

  var p = -1,
      k =  0;
  while(fp[delta+offset].y < N){
    p = p + 1;
    for(k = -p; k < delta; ++k){
      snake(k);
    }
    for(k = delta+p; k > delta; --k){
      snake(k);
    }
    snake(delta);
  }

  var current = fp[delta+offset];
  current.d = delta + 2 * p;
  var type = null, a_index = M - 1, b_index = N - 1;
  for(var i = current.tree; i != null; i = i.prev){
    type = i.type;
    if(type === '+'){
      mC.unshift('<em class=c2>'+ B[b_index] + "</em>");
      --b_index;
    } else if(type === '-'){
      mC.unshift('<em class=c1>'+ A[a_index] + "</em>");
      --a_index;
    } else {
      mC.unshift(A[a_index] );
      --a_index;
      --b_index;
    }
  }
}

</script>
</head>

<body onload="init()">
<form name="test">
    <input type="button" value="Compare" onClick="hikaku()">
</form>

<table ><tr>
<td>text 1 <br/><textarea id="ss1" >{!text2}</textarea></td>
<td>text 2 <br/><textarea id="ss2" >{!text1}</textarea></td>
</tr></table>

<div id="sat1">
</div>
    </body>
</html>

質問失礼します。
改行コードが含まれているStringの文字列対し、一文字ずつ間にスペースを入れたいです。

改行コード「'\r\n'」がいくつ含まれているか調べるにはどのようにしてコードを書けばよろしいでしょうか?
その数+1回をfor文でループし、その中で改行コード「'\r\n'」以外の文字と文字の間に空白を入れたらできるのかなと思って取り組んでいます。
文字列を渡し、一文字ずつ空白を入れて(改行コード以外に)戻り値とするメソッドを作成したいです。

誰か力を貸してください

ex)
Before)
aaa
bbb
ccc

After)
a a a
b b b
c c c

 

Thank you for your help.

I would like to use Javascript variables for rendered and style attributes in Visualforce.

1.
How should I describe the Javascript variables in Visualforce?

2.
Can I rewrite attributes of Visualforce tags?
If you can, please let me know.
ラッパー
質問失礼します。

ラッパークラスを作成し、選択したレコードをクラス内の変数に保ちたいです。

どのように実装したらよろしいでしょうか?
イメージとしては、ボタンを作成しボタン押下したら、変数に保持しデバッグ出力したいです。

Visualforce
<apex:page controller="CheckboxTableViewController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="1">
                <apex:pageBlockTable value="{!wrappers}" var="item">
                    <apex:column style="width: 20px;">
                        <apex:inputCheckbox value="{!item.isChecked}" />
                    </apex:column>
                    <apex:column headerValue="Name">
                        <apex:outputText value="{!item.name}" />
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

コントローラ
public with sharing class CheckboxTableViewController {
    
    public List<CheckboxTableViewWrapper> wrappers {get; set;}
    
    public CheckboxTableViewController() {
        this.wrappers = getWrappers();
    }
    
    private List<CheckboxTableViewWrapper> getWrappers() {
        
        List<CheckboxTableViewWrapper> lists = new List<CheckboxTableViewWrapper>();
        
        Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
        List<Schema.PicklistEntry> pickListEntry = fieldResult.getPicklistValues();
        
        for (Schema.PicklistEntry pick: pickListEntry) {
            lists.add(new CheckboxTableViewWrapper(pick.getLabel()));
        }
        
        return lists;
    }
}

ラッパークラス
public with sharing class CheckboxTableViewWrapper {
    
    public Boolean isChecked {get; set;}
    public String name {get; set;}
    
    public CheckboxTableViewWrapper() {
        this.isChecked = false;
        this.name = '';
    }
    
    public CheckboxTableViewWrapper(String prmName) {
        this.isChecked = false;
        this.name = prmName;
    }
}


どなたかお力化していただけたら幸いです。
よろしくお願いいたします。​​​​​​​
  • September 25, 2023
  • Like
  • 0
質問失礼します。

二つのテキストを比較し、差分を表現する画面です。
以下のコードの内容を教えてください。
他人のコードなのですが、私は初心者なので、どうしても理解できない箇所があります。

Question(1)
HTMLの"td.d1"や"td.d1 em.c1"などの記述がありますが、どこにも定義されておりませんが、どこを指している(何を意味している)のでしょうか?

Question(2)
Javascriptで、function diffxが何を行っているのかが分かりません。
一行ずつ解読しているのですが、どなたか一行ずつ解説を教えていただけませんでしょうか?

悩んで分からないので、助けていただければと思います。
初心者の私には難しいです。
よろしくお願いいたします。
-------

↓コード

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>HIKAKU</title>
<style type="text/css">
    body {
        background-color: #eeeeee; 
        color: #000000; 
        margin: 2; 
        padding: 2;
        font-family: Helvetica;
    }
    div {
        background-color: #dddddd;
        border: 1px solid #ff5555; 
    }

    table{
        width: 100%;
        border-collapse: collapse;
    }
    tr{
        width: 98%;
    }
    textarea {
        width: 98%;
        height: 200px;
        border: 2px solid #ffcc77; 
    }
    td {
        width: 10%;
        background-color: #ffffff;
        border-right: 1px dotted #555555; 
        border-bottom: 1px dotted #555555; 
        color: #000000;
        font-size: 12px;
        padding: 2px; 
        text-decoration: none;
        font-style: normal;
        word-break: break-all;
        vertical-align: top;
        vertical-align: baseline;
    }
    td.d1 {
        background-color: #ffffff;
        color: #000000;
        text-decoration: none;
        font-style: normal;
    }
    td.d2 {
        background-color: #ffffff;
        color: #000000;
        text-decoration: none;
        font-style: normal;
    }
    td.d1 em.c1 {
        background-color: #FF0000;
        display: none;/**/
    }
    td.d1 em.c2 {
        background-color: #88ff88;
    }
    td.d2 em.c1 {
        background-color: #8888ff;
    }
    td.d2 em.c2 {
        background-color: #ffff00;
        display: none;/**/
    }
    em.c1 {
        text-decoration: none;
        font-style: normal;
        vertical-align: baseline;
    }
    em.c2 {
        text-decoration: none;
        font-style: normal;
        vertical-align: baseline;
    }
</style>
<script type="text/javascript">
var fp = new Array();
var A = new Array();
var B = new Array();
var N;
var M;
var mC = new Array();

function init(){
        document.getElementById('ss1').value = sample_txt[0].t;
        document.getElementById('ss2').value = sample_txt[1].t;
}

function hikaku(){
            mC = new Array();
            s1 = document.getElementById('ss1').value;
            s2 = document.getElementById('ss2').value;
            diffx(s1, s2);
            var qa,qb;
            if(s1.length<=s2.length){
              qa = 1;
              qb = 2;
            }else{
              qa = 2;
              qb = 1;
            }
            var aa = mC.join("").split("\n");
            var ht = "";
            document.getElementById('sat1').innerHTML = "";
            for(var i = 0, len = aa.length; i < len; ++i){
                ht = ht + "<tr><td class=\"d"+qa+"\">" + aa[i] + "</td><td class=\"d"+qb+"\">" + aa[i] + "</td></tr>";
            }
            document.getElementById('sat1').innerHTML = "<table>" + ht + "</table>";
            ht = "";
}

function diffx(c1r, c2r){
  var A = c1r.split('');
  var B = c2r.split('');
  var M = A.length;
  var N = B.length;

  var exchanged = false;

  if(N > M){
    exchanged = true;
    var t;
    t = A;
    A = B;
    B = t;
    t = M;
    M = N;
    N = t;
  }

  var offset = N;
  var delta = M - N;
  var size = M + N + 1;
  for(var i = 0, fp = []; i < size; ++i){
    fp[i] = {
      y    : null,
      tree : null
    }
  }
  var snake = function(k){
    if((k < -N) || (M < k)){
      return;
    } else {
      var current = fp[k+offset];
      if(k === -N){
        var down  = fp[k+1+offset];
        current.y = down.y+1;
        current.tree = {
          type : '+',
          prev : down.tree
        }
      } else if(k === M){
        var slide = fp[k-1+offset];
        current.y = slide.y;
        current.tree = {
          type : '-',
          prev : slide.tree
        }
      } else {
        var slide = fp[k-1+offset];
        var down  = fp[k+1+offset];
        if(slide.y === null && down.y === null){
          current.y = 0;
        } else if(down.y === null || slide.y === null){
          if(down.y === null){
            current.y = slide.y;
            current.tree = {
              type : '-',
              prev : slide.tree
            }
          } else {
            current.y = down.y+1;
            current.tree = {
              type : '+',
              prev : down.tree
            }
          }
        } else {
          if(slide.y > (down.y+1)){
            current.y = slide.y;
            current.tree = {
              type : '-',
              prev : slide.tree
            }
          } else {
            current.y = down.y+1;
            current.tree = {
              type : '+',
              prev : down.tree
            }
          }
        }
      }
      var y = current.y;
      var x = y + k;
      while(x < M && y < N && A[x] === B[y]){
        current.tree = {
          type : '|',
          prev : current.tree
        }
        x++;
        y++;
      }
      current.y = y;
    }
  }

  var p = -1,
      k =  0;
  while(fp[delta+offset].y < N){
    p = p + 1;
    for(k = -p; k < delta; ++k){
      snake(k);
    }
    for(k = delta+p; k > delta; --k){
      snake(k);
    }
    snake(delta);
  }

  var current = fp[delta+offset];
  current.d = delta + 2 * p;
  var type = null, a_index = M - 1, b_index = N - 1;
  for(var i = current.tree; i != null; i = i.prev){
    type = i.type;
    if(type === '+'){
      mC.unshift('<em class=c2>'+ B[b_index] + "</em>");
      --b_index;
    } else if(type === '-'){
      mC.unshift('<em class=c1>'+ A[a_index] + "</em>");
      --a_index;
    } else {
      mC.unshift(A[a_index] );
      --a_index;
      --b_index;
    }
  }
}

</script>
</head>

<body onload="init()">
<form name="test">
    <input type="button" value="Compare" onClick="hikaku()">
</form>

<table ><tr>
<td>text 1 <br/><textarea id="ss1" >{!text2}</textarea></td>
<td>text 2 <br/><textarea id="ss2" >{!text1}</textarea></td>
</tr></table>

<div id="sat1">
</div>
    </body>
</html>