Legacy Knowledge Base
公開されました Sep. 10, 2025

instance-id'フィールドとは何ですか?

Written By

Jose L. Bango

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

問題

  • instace-idまたはinstanceIdフィールドとは何ですか?

環境

  • すべてのLiferayバージョン

解像度

  • ランダムな英数字だ。
  • Liferayはこの値を使ってフィールドを一意に識別できるようにします。
  • 実際の生成サンプルコード:
    • JS(fieldSupport.js)
      export function generateInstanceId(isNumbersOnly) {
      return Math.random()
      .toString(isNumbersOnly ? 10 : 36)
      .substr(2, 8);
      }
    • Java(StringUtil.randomString()メソッドを使用)
      public static String randomString(int length) {
      Random random = new Random();

      char[] chars = new char[length];

      for (int i = 0; i < length; i++) {
      int index = random.nextInt(_RANDOM_STRING_CHAR_TABLE.length);

      chars[i] = _RANDOM_STRING_CHAR_TABLE[index];
      }

      return new String(chars);
      }

追加情報

  • フィールドIDの生成に使われることもあるが、これも一意でなければならない。 W3C DOM#getElementById()に従います。
    • 複数の要素がその値を持つID属性を持つ場合、返される値は未定義です。
Did this article resolve your issue ?

Legacy Knowledge Base